00001 #ifndef INPUT_SPEEX_H 00002 #define INPUT_SPEEX_H 00003 00004 00005 #include <memory> 00006 #include "speexfile/speexfile.h" 00007 #include "audiere.h" 00008 #include "basic_source.h" 00009 #include "types.h" 00010 #include "utility.h" 00011 00012 00013 namespace audiere { 00014 00015 class SpeexInputStream : public BasicSource { 00016 public: 00017 SpeexInputStream(); 00018 ~SpeexInputStream(); 00019 00020 bool initialize(FilePtr file); 00021 00022 void ADR_CALL getFormat( 00023 int& channel_count, 00024 int& sample_rate, 00025 SampleFormat& sample_format); 00026 int doRead(int frame_count, void* buffer); 00027 void ADR_CALL reset(); 00028 00029 bool ADR_CALL isSeekable(); 00030 int ADR_CALL getLength(); 00031 void ADR_CALL setPosition(int position); 00032 int ADR_CALL getPosition(); 00033 00034 private: 00035 bool findFormatChunk(); 00036 bool findDataChunk(); 00037 bool skipBytes(int size); 00038 00039 private: 00040 // Defined by speexfile API. 00041 enum { BUFFER_SIZE = 2000 }; 00042 00043 std::auto_ptr<speexfile::Reader> m_reader; 00044 00045 speexfile::speexfile* m_speexfile; 00046 int m_position; // Need to remember this because m_speexfile doesn't. 00047 00048 QueueBuffer m_read_buffer; 00049 }; 00050 00051 } 00052 00053 00054 #endif