comparison data/fileio/MP3FileReader.h @ 392:183ee2a55fc7

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents 700cd3350391
children a4b8ad0f1a8f
comparison
equal deleted inserted replaced
391:5858cc462d0a 392:183ee2a55fc7
23 #include "base/Thread.h" 23 #include "base/Thread.h"
24 #include <mad.h> 24 #include <mad.h>
25 25
26 #include <set> 26 #include <set>
27 27
28 class QProgressDialog; 28 class ProgressReporter;
29 29
30 class MP3FileReader : public CodedAudioFileReader 30 class MP3FileReader : public CodedAudioFileReader
31 { 31 {
32 Q_OBJECT
33
32 public: 34 public:
33 enum DecodeMode { 35 enum DecodeMode {
34 DecodeAtOnce, // decode the file on construction, with progress dialog 36 DecodeAtOnce, // decode the file on construction, with progress
35 DecodeThreaded // decode in a background thread after construction 37 DecodeThreaded // decode in a background thread after construction
36 }; 38 };
37 39
38 MP3FileReader(FileSource source, 40 MP3FileReader(FileSource source,
39 DecodeMode decodeMode, 41 DecodeMode decodeMode,
40 CacheMode cacheMode, 42 CacheMode cacheMode,
41 size_t targetRate = 0); 43 size_t targetRate = 0,
44 ProgressReporter *reporter = 0);
42 virtual ~MP3FileReader(); 45 virtual ~MP3FileReader();
43 46
44 virtual QString getError() const { return m_error; } 47 virtual QString getError() const { return m_error; }
45 48
46 virtual QString getLocation() const { return m_source.getLocation(); } 49 virtual QString getLocation() const { return m_source.getLocation(); }
56 59
57 virtual bool isUpdating() const { 60 virtual bool isUpdating() const {
58 return m_decodeThread && m_decodeThread->isRunning(); 61 return m_decodeThread && m_decodeThread->isRunning();
59 } 62 }
60 63
64 public slots:
65 void cancelled();
66
61 protected: 67 protected:
62 FileSource m_source; 68 FileSource m_source;
63 QString m_path; 69 QString m_path;
64 QString m_error; 70 QString m_error;
65 QString m_title; 71 QString m_title;
72 78
73 unsigned char *m_filebuffer; 79 unsigned char *m_filebuffer;
74 float **m_samplebuffer; 80 float **m_samplebuffer;
75 size_t m_samplebuffersize; 81 size_t m_samplebuffersize;
76 82
77 QProgressDialog *m_progress; 83 ProgressReporter *m_reporter;
78 bool m_cancelled; 84 bool m_cancelled;
79 85
80 struct DecoderData 86 struct DecoderData
81 { 87 {
82 unsigned char const *start; 88 unsigned char const *start;