00001 #ifndef INPUT_FLAC_H 00002 #define INPUT_FLAC_H 00003 00004 00005 #include <FLAC/seekable_stream_decoder.h> 00006 #include "audiere.h" 00007 #include "basic_source.h" 00008 #include "utility.h" 00009 00010 00011 namespace audiere { 00012 00013 class FLACInputStream : public BasicSource { 00014 public: 00015 FLACInputStream(); 00016 ~FLACInputStream(); 00017 00018 bool initialize(FilePtr file); 00019 00020 void ADR_CALL getFormat( 00021 int& channel_count, 00022 int& sample_rate, 00023 SampleFormat& sampleformat); 00024 int doRead(int frame_count, void* samples); 00025 void ADR_CALL reset(); 00026 00027 bool ADR_CALL isSeekable(); 00028 int ADR_CALL getLength(); 00029 void ADR_CALL setPosition(int position); 00030 int ADR_CALL getPosition(); 00031 00032 private: 00033 FLAC__StreamDecoderWriteStatus write( 00034 const FLAC__Frame* frame, 00035 const FLAC__int32* const buffer[]); 00036 00037 static FLAC__SeekableStreamDecoderReadStatus read_callback( 00038 const FLAC__SeekableStreamDecoder* decoder, 00039 FLAC__byte buffer[], 00040 unsigned* bytes, 00041 void* client_data); 00042 static FLAC__SeekableStreamDecoderSeekStatus seek_callback( 00043 const FLAC__SeekableStreamDecoder* decoder, 00044 FLAC__uint64 absolute_byte_offset, 00045 void* client_data); 00046 static FLAC__SeekableStreamDecoderTellStatus tell_callback( 00047 const FLAC__SeekableStreamDecoder* decoder, 00048 FLAC__uint64* absolute_byte_offset, 00049 void* client_data); 00050 static FLAC__SeekableStreamDecoderLengthStatus length_callback( 00051 const FLAC__SeekableStreamDecoder* decoder, 00052 FLAC__uint64* stream_length, 00053 void* client_data); 00054 static FLAC__bool eof_callback( 00055 const FLAC__SeekableStreamDecoder* decoder, 00056 void* client_data); 00057 static FLAC__StreamDecoderWriteStatus write_callback( 00058 const FLAC__SeekableStreamDecoder* decoder, 00059 const FLAC__Frame* frame, 00060 const FLAC__int32* const buffer[], 00061 void* client_data); 00062 static void metadata_callback( 00063 const FLAC__SeekableStreamDecoder* decoder, 00064 const FLAC__StreamMetadata* metadata, 00065 void* client_data); 00066 static void error_callback( 00067 const FLAC__SeekableStreamDecoder* decoder, 00068 FLAC__StreamDecoderErrorStatus status, 00069 void* client_data); 00070 00071 static FLACInputStream* getStream(void* client_data); 00072 static File* getFile(void* client_data); 00073 00074 00075 FilePtr m_file; 00076 00077 FLAC__SeekableStreamDecoder* m_decoder; 00078 00084 SizedBuffer m_multiplexer; 00085 00090 QueueBuffer m_buffer; 00091 00092 int m_channel_count; 00093 int m_sample_rate; 00094 SampleFormat m_sample_format; 00095 00096 int m_length; 00097 int m_position; 00098 }; 00099 00100 } 00101 00102 00103 #endif