00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_SOUNDDECODER_H
00023 #define FIFE_SOUNDDECODER_H
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "soundconfig.h"
00037 #include "fife_openal.h"
00038
00039 namespace FIFE {
00040
00041 class SoundDecoder {
00042 public:
00043
00044 virtual ~SoundDecoder() {}
00045
00048 virtual unsigned long getDecodedLength() const = 0;
00049
00059 bool needsStreaming() const { return getDecodedLength() > MAX_KEEP_IN_MEM; }
00060
00065 virtual bool setCursor(unsigned long pos) = 0;
00066
00072 virtual bool decode(unsigned long length) = 0;
00073
00078 virtual void *getBuffer() const = 0;
00079
00082 virtual unsigned long getBufferSize() = 0;
00083
00086 virtual void releaseBuffer() = 0;
00087
00092 bool isStereo() const {
00093 return m_isstereo;
00094 }
00095
00098 ALenum getALFormat() const {
00099 if (m_isstereo) {
00100 return m_is8bit ? AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16;
00101 } else {
00102 return m_is8bit ? AL_FORMAT_MONO8 : AL_FORMAT_MONO16;
00103 }
00104 }
00105
00108 short getBitResolution() const {
00109 return m_is8bit ? 8 : 16;
00110 }
00111
00114 unsigned long getSampleRate() const{
00115 return m_samplerate;
00116 }
00117
00118 protected:
00119 bool m_isstereo;
00120 bool m_is8bit;
00121 unsigned long m_samplerate;
00122 };
00123 }
00124
00125 #endif