OpenMW
apps/openmw/mwsound/mpgsnd_decoder.hpp
Go to the documentation of this file.
00001 #ifndef GAME_SOUND_MPGSND_DECODER_H
00002 #define GAME_SOUND_MPGSND_DECODER_H
00003 
00004 #include <string>
00005 
00006 #include <OgreDataStream.h>
00007 
00008 #include "mpg123.h"
00009 #include "sndfile.h"
00010 
00011 #include "sound_decoder.hpp"
00012 
00013 
00014 namespace MWSound
00015 {
00016     class MpgSnd_Decoder : public Sound_Decoder
00017     {
00018         SF_INFO mSndInfo;
00019         SNDFILE *mSndFile;
00020         mpg123_handle *mMpgFile;
00021 
00022         Ogre::DataStreamPtr mDataStream;
00023         static sf_count_t ogresf_get_filelen(void *user_data);
00024         static sf_count_t ogresf_seek(sf_count_t offset, int whence, void *user_data);
00025         static sf_count_t ogresf_read(void *ptr, sf_count_t count, void *user_data);
00026         static sf_count_t ogresf_write(const void*, sf_count_t, void*);
00027         static sf_count_t ogresf_tell(void *user_data);
00028         static ssize_t ogrempg_read(void*, void*, size_t);
00029         static off_t ogrempg_lseek(void*, off_t, int);
00030 
00031         ChannelConfig mChanConfig;
00032         int mSampleRate;
00033 
00034         virtual void open(const std::string &fname);
00035         virtual void close();
00036 
00037         virtual std::string getName();
00038         virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
00039 
00040         virtual size_t read(char *buffer, size_t bytes);
00041         virtual void readAll(std::vector<char> &output);
00042         virtual void rewind();
00043         virtual size_t getSampleOffset();
00044 
00045         MpgSnd_Decoder& operator=(const MpgSnd_Decoder &rhs);
00046         MpgSnd_Decoder(const MpgSnd_Decoder &rhs);
00047 
00048         MpgSnd_Decoder();
00049     public:
00050         virtual ~MpgSnd_Decoder();
00051 
00052         friend class SoundManager;
00053     };
00054 #ifndef DEFAULT_DECODER
00055 #define DEFAULT_DECODER (::MWSound::MpgSnd_Decoder)
00056 #endif
00057 }
00058 
00059 #endif