comparison data/fileio/WavFileWriter.h @ 684:bcca512445f3

Provide option for WavFileWriter to write directly to target file, rather than always using a temporary; make use of it in WritableWaveFileModel so we can read from target file without having to close it first
author Chris Cannam
date Wed, 11 May 2011 11:04:35 +0100
parents 920e3880f7b4
children 59e7fe1b1003
comparison
equal deleted inserted replaced
683:f84f147572b9 684:bcca512445f3
25 class TempWriteFile; 25 class TempWriteFile;
26 26
27 class WavFileWriter 27 class WavFileWriter
28 { 28 {
29 public: 29 public:
30 WavFileWriter(QString path, size_t sampleRate, size_t channels); 30 /**
31 * Specify the method used to open the destination file.
32 *
33 * If WriteToTemporary, the destination will be opened as a
34 * temporary file which is moved to the target location when the
35 * WavFileWriter is closed or deleted (to avoid clobbering an
36 * existing file with a partially written replacement).
37 *
38 * If WriteToTarget, the target file will be opened directly
39 * (necessary when e.g. doing a series of incremental writes to a
40 * file while keeping it open for reading).
41 */
42 enum FileWriteMode {
43 WriteToTemporary,
44 WriteToTarget
45 };
46
47 WavFileWriter(QString path, size_t sampleRate, size_t channels,
48 FileWriteMode mode);
31 virtual ~WavFileWriter(); 49 virtual ~WavFileWriter();
32 50
33 bool isOK() const; 51 bool isOK() const;
34 52
35 virtual QString getError() const; 53 virtual QString getError() const;
48 size_t m_sampleRate; 66 size_t m_sampleRate;
49 size_t m_channels; 67 size_t m_channels;
50 TempWriteFile *m_temp; 68 TempWriteFile *m_temp;
51 SNDFILE *m_file; 69 SNDFILE *m_file;
52 QString m_error; 70 QString m_error;
71
72 QString getWriteFilename() const;
53 }; 73 };
54 74
55 75
56 #endif 76 #endif