comparison data/fileio/OggVorbisFileReader.h @ 263:71dfc6ab3b54

* Threaded mp3/ogg file reading. Not activated yet, as it doesn't work in context (SV needs to know the duration of its main model at the outset)
author Chris Cannam
date Thu, 24 May 2007 16:20:22 +0000
parents c03ec31005e1
children e08f486e8d8c
comparison
equal deleted inserted replaced
262:524bcd89743b 263:71dfc6ab3b54
19 #ifdef HAVE_OGGZ 19 #ifdef HAVE_OGGZ
20 #ifdef HAVE_FISHSOUND 20 #ifdef HAVE_FISHSOUND
21 21
22 #include "CodedAudioFileReader.h" 22 #include "CodedAudioFileReader.h"
23 23
24 #include "base/Thread.h"
24 #include <oggz/oggz.h> 25 #include <oggz/oggz.h>
25 #include <fishsound/fishsound.h> 26 #include <fishsound/fishsound.h>
26 27
27 #include <set> 28 #include <set>
28 29
29 class QProgressDialog; 30 class QProgressDialog;
30 31
31 class OggVorbisFileReader : public CodedAudioFileReader 32 class OggVorbisFileReader : public CodedAudioFileReader
32 { 33 {
33 public: 34 public:
34 OggVorbisFileReader(QString path, bool showProgress, CacheMode cacheMode); 35 enum DecodeMode {
36 DecodeAtOnce, // decode the file on construction, with progress dialog
37 DecodeThreaded // decode in a background thread after construction
38 };
39
40 OggVorbisFileReader(QString path, DecodeMode decodeMode,
41 CacheMode cacheMode);
35 virtual ~OggVorbisFileReader(); 42 virtual ~OggVorbisFileReader();
36 43
37 virtual QString getError() const { return m_error; } 44 virtual QString getError() const { return m_error; }
38 45
39 static void getSupportedExtensions(std::set<QString> &extensions); 46 static void getSupportedExtensions(std::set<QString> &extensions);
40 47
48 virtual bool isUpdating() const {
49 return m_decodeThread && m_decodeThread->isRunning();
50 }
51
41 protected: 52 protected:
42 QString m_path; 53 QString m_path;
43 QString m_error; 54 QString m_error;
44 55
56 OGGZ *m_oggz;
45 FishSound *m_fishSound; 57 FishSound *m_fishSound;
46 QProgressDialog *m_progress; 58 QProgressDialog *m_progress;
47 size_t m_fileSize; 59 size_t m_fileSize;
48 size_t m_bytesRead; 60 size_t m_bytesRead;
49 bool m_cancelled; 61 bool m_cancelled;
50 62
51 static int readPacket(OGGZ *, ogg_packet *, long, void *); 63 static int readPacket(OGGZ *, ogg_packet *, long, void *);
52 static int acceptFrames(FishSound *, float **, long, void *); 64 static int acceptFrames(FishSound *, float **, long, void *);
65
66 class DecodeThread : public Thread
67 {
68 public:
69 DecodeThread(OggVorbisFileReader *reader) : m_reader(reader) { }
70 virtual void run();
71
72 protected:
73 OggVorbisFileReader *m_reader;
74 };
75
76 DecodeThread *m_decodeThread;
53 }; 77 };
54 78
55 #endif 79 #endif
56 #endif 80 #endif
57 81