00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_SOUNDCLIP_H_
00023 #define FIFE_SOUNDCLIP_H_
00024
00025
00026 #include <vector>
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "util/resource/resource.h"
00037
00038 #include "sounddecoder.h"
00039
00040 namespace FIFE {
00041
00044 enum SoundPositionType {
00045 SD_SAMPLE_POS,
00046 SD_TIME_POS,
00047 SD_BYTE_POS
00048 };
00049
00050 struct SoundBufferEntry {
00051 ALuint buffers[BUFFER_NUM];
00052 uint32_t usedbufs;
00053 uint64_t deccursor;
00054 };
00055
00058 class SoundClip : public IResource {
00059 public:
00060
00061 SoundClip(IResourceLoader* loader = 0);
00062 SoundClip(const std::string& name, IResourceLoader* loader = 0);
00063
00064 ~SoundClip();
00065
00070 bool isStream() const {
00071 return m_isstream;
00072 }
00073
00079 uint32_t countBuffers() const {
00080 return m_buffervec.at(0)->usedbufs;
00081 }
00082
00086 ALuint* getBuffers(uint32_t streamid = 0) const {
00087 return m_buffervec.at(streamid)->buffers;
00088 }
00089
00093 uint32_t beginStreaming();
00094
00099 void acquireStream(uint32_t streamid);
00100
00104 bool setStreamPos(uint32_t streamid, SoundPositionType type, float value);
00105
00108 float getStreamPos(uint32_t streamid, SoundPositionType type) const;
00109
00115 bool getStream(uint32_t streamid, ALuint buffer);
00116
00119 void quitStreaming(uint32_t streamid);
00120
00123 void adobtDecoder(SoundDecoder* decoder) { m_decoder = decoder; m_deletedecoder = true; }
00124
00127 void setDecoder(SoundDecoder* decoder) { m_decoder = decoder; m_deletedecoder = false; }
00128
00131 SoundDecoder* getDecoder() const {
00132 return m_decoder;
00133 }
00134
00135 virtual size_t getSize() { return 0; }
00136
00137 virtual void load();
00138 virtual void free();
00139
00140 private:
00141 bool m_isstream;
00142 SoundDecoder* m_decoder;
00143 bool m_deletedecoder;
00144 std::vector<SoundBufferEntry*> m_buffervec;
00145
00146 std::string createUniqueClipName();
00147 };
00148
00149 typedef SharedPtr<SoundClip> SoundClipPtr;
00150 }
00151
00152 #endif