OpenMW
apps/openmw/mwsound/sound_decoder.hpp
Go to the documentation of this file.
00001 #ifndef GAME_SOUND_SOUND_DECODER_H
00002 #define GAME_SOUND_SOUND_DECODER_H
00003 
00004 #include <string>
00005 
00006 #include <OgreResourceGroupManager.h>
00007 
00008 namespace MWSound
00009 {
00010     enum SampleType {
00011         SampleType_UInt8,
00012         SampleType_Int16,
00013         SampleType_Float32
00014     };
00015     const char *getSampleTypeName(SampleType type);
00016 
00017     enum ChannelConfig {
00018         ChannelConfig_Mono,
00019         ChannelConfig_Stereo,
00020         ChannelConfig_Quad,
00021         ChannelConfig_5point1,
00022         ChannelConfig_7point1
00023     };
00024     const char *getChannelConfigName(ChannelConfig config);
00025 
00026     size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type);
00027     size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type);
00028 
00029     struct Sound_Decoder
00030     {
00031         Ogre::ResourceGroupManager &mResourceMgr;
00032 
00033         virtual void open(const std::string &fname) = 0;
00034         virtual void close() = 0;
00035 
00036         virtual std::string getName() = 0;
00037         virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
00038 
00039         virtual size_t read(char *buffer, size_t bytes) = 0;
00040         virtual void readAll(std::vector<char> &output);
00041         virtual void rewind() = 0;
00042         virtual size_t getSampleOffset() = 0;
00043 
00044         Sound_Decoder() : mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
00045         { }
00046         virtual ~Sound_Decoder() { }
00047 
00048     private:
00049         Sound_Decoder(const Sound_Decoder &rhs);
00050         Sound_Decoder& operator=(const Sound_Decoder &rhs);
00051     };
00052 }
00053 
00054 #endif