From 4c6d7ab4d79c3a509f5702278aaf7f14df3f2a4c Mon Sep 17 00:00:00 2001 From: vsonnier Date: Sun, 14 Jan 2018 15:30:40 +0100 Subject: [PATCH] Fix wrong multi-part WAV sequence management with time-limit files --- src/audio/AudioFileWAV.cpp | 13 +++++++++++++ src/audio/AudioFileWAV.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/audio/AudioFileWAV.cpp b/src/audio/AudioFileWAV.cpp index ad4078f..d0629ab 100644 --- a/src/audio/AudioFileWAV.cpp +++ b/src/audio/AudioFileWAV.cpp @@ -65,9 +65,11 @@ std::string AudioFileWAV::getExtension() bool AudioFileWAV::writeToFile(AudioThreadInputPtr input) { if (!outputFileStream.is_open()) { + std::string ofName = getOutputFileName(); outputFileStream.open(ofName.c_str(), std::ios::binary); + currentFileSize = 0; writeHeaderToFileStream(input); } @@ -111,6 +113,7 @@ bool AudioFileWAV::closeFile() write_word(outputFileStream, file_length - 8, 4); outputFileStream.close(); + currentFileSize = 0; } return true; @@ -169,6 +172,16 @@ size_t AudioFileWAV::getMaxWritableNumberOfSamples(AudioThreadInputPtr input) { } +void AudioFileWAV::setOutputFileName(std::string filename) { + + if (filename != filenameBase) { + + currentSequenceNumber = 0; + } + + AudioFile::setOutputFileName(filename); +} + std::string AudioFileWAV::getOutputFileName() { std::string recPath = wxGetApp().getConfig()->getRecordingPath(); diff --git a/src/audio/AudioFileWAV.h b/src/audio/AudioFileWAV.h index dcd102d..1dc9672 100644 --- a/src/audio/AudioFileWAV.h +++ b/src/audio/AudioFileWAV.h @@ -13,6 +13,9 @@ public: AudioFileWAV(); ~AudioFileWAV(); + //override to manage name change with multi-part WAV. + virtual void setOutputFileName(std::string filename); + //override of the base method to generate multi-part //WAV to overcome the WAV format size limit. virtual std::string getOutputFileName();