00001 /* 00002 $Id: mpeg_soundprovider.h,v 1.2 2000/07/15 15:45:50 starch Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #ifndef header_mpeg_soundprovider 00016 #define header_mpeg_soundprovider 00017 00018 #include "../Core/Sound/stream_soundprovider.h" 00019 #include <MPEG/MPEG.h> 00020 00021 class CL_MPEGSoundProvider : public CL_StreamSoundProvider 00022 //: Streamed MPEG audio stream sound provider. 00023 { 00024 public: 00025 CL_MPEGSoundProvider(const char *filename); 00026 virtual ~CL_MPEGSoundProvider(); 00027 00028 virtual CL_StreamSoundProvider_Session *begin_session(); 00029 virtual void end_session(CL_StreamSoundProvider_Session *session); 00030 00031 private: 00032 std::string file; 00033 }; 00034 00035 class CL_MPEGSoundProvider_Session : public CL_StreamSoundProvider_Session, MPEGAudioDrv 00036 { 00037 public: 00038 CL_MPEGSoundProvider_Session(const char *filename); 00039 virtual ~CL_MPEGSoundProvider_Session(); 00040 00041 virtual bool eof() const; 00042 //: Returns true if no more input data is available. 00044 00045 virtual void stop(); 00046 //: Stops the current stream. 00047 00048 virtual bool play(); 00049 //: Start/continue playing of the stream. 00051 00052 virtual bool set_position(int pos); 00053 //: Sets the position within the current stream. 00056 00057 virtual int get_data(void *data_ptr, int data_requested); 00058 //: Called when a playback session needs more sample data. 00063 00064 virtual int get_frequency() const; 00065 //: Returns the playback frequency of the input data. 00067 00068 virtual SoundFormat get_format() const; 00069 //: Returns the playback sample format. 00071 00072 protected: 00073 // MPEGAudioDrv interface: 00074 virtual bool Open(MPEGAudioSpec *desired, MPEGAudioSpec *optained); 00075 virtual void Close(); 00076 virtual void Pause(bool enable); 00077 virtual void Mix(Uint8 *dst, Uint8 *src, Uint32 len, int volume); 00078 virtual void Lock(); 00079 virtual void Unlock(); 00080 virtual int GetMaxVolume(); 00081 virtual char *GetError(); 00082 00083 private: 00084 MPEG *mpeg; 00085 MPEGAudioSpec audiospec; 00086 }; 00087 00088 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001