comparison data/fileio/WavFileReader.h @ 823:f0558e69a074

Rename Resampling- to DecodingWavFileReader, and use it whenever we have an audio file that is not quickly seekable using libsndfile. Avoids very slow performance when analysing ogg files.
author Chris Cannam
date Wed, 17 Jul 2013 15:40:01 +0100
parents 700cd3350391
children 59e7fe1b1003
comparison
equal deleted inserted replaced
821:06c64a1c6785 823:f0558e69a074
21 #include <sndfile.h> 21 #include <sndfile.h>
22 #include <QMutex> 22 #include <QMutex>
23 23
24 #include <set> 24 #include <set>
25 25
26 /**
27 * Reader for audio files using libsndfile.
28 *
29 * This is typically intended for seekable file types that can be read
30 * directly (e.g. WAV, AIFF etc).
31 *
32 * Compressed files supported by libsndfile (e.g. Ogg, FLAC) should
33 * normally be read using DecodingWavFileReader instead (which decodes
34 * to an intermediate cached file).
35 */
26 class WavFileReader : public AudioFileReader 36 class WavFileReader : public AudioFileReader
27 { 37 {
28 public: 38 public:
29 WavFileReader(FileSource source, bool fileUpdating = false); 39 WavFileReader(FileSource source, bool fileUpdating = false);
30 virtual ~WavFileReader(); 40 virtual ~WavFileReader();
31 41
32 virtual QString getLocation() const { return m_source.getLocation(); } 42 virtual QString getLocation() const { return m_source.getLocation(); }
33 virtual QString getError() const { return m_error; } 43 virtual QString getError() const { return m_error; }
34 44
45 virtual bool isQuicklySeekable() const { return m_seekable; }
46
35 /** 47 /**
36 * Must be safe to call from multiple threads with different 48 * Must be safe to call from multiple threads with different
37 * arguments on the same object at the same time. 49 * arguments on the same object at the same time.
38 */ 50 */
39 virtual void getInterleavedFrames(size_t start, size_t count, 51 virtual void getInterleavedFrames(size_t start, size_t count,
57 69
58 FileSource m_source; 70 FileSource m_source;
59 QString m_path; 71 QString m_path;
60 QString m_error; 72 QString m_error;
61 73
74 bool m_seekable;
75
62 mutable QMutex m_mutex; 76 mutable QMutex m_mutex;
63 mutable float *m_buffer; 77 mutable float *m_buffer;
64 mutable size_t m_bufsiz; 78 mutable size_t m_bufsiz;
65 mutable size_t m_lastStart; 79 mutable size_t m_lastStart;
66 mutable size_t m_lastCount; 80 mutable size_t m_lastCount;