FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_SOUNDCLIP_H_ 00023 #define FIFE_SOUNDCLIP_H_ 00024 00025 // Standard C++ library includes 00026 #include <vector> 00027 00028 // Platform specific includes 00029 00030 // 3rd party library includes 00031 00032 // FIFE includes 00033 // These includes are split up in two parts, separated by one empty line 00034 // First block: files included from the FIFE root src directory 00035 // Second block: files included from the same folder 00036 #include "util/base/resourceclass.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 unsigned int usedbufs; 00053 unsigned long deccursor; 00054 }; 00055 00058 class SoundClip : public ResourceClass { 00059 public: 00060 00061 SoundClip(SoundDecoder* decptr, bool deletedecoder = true); 00062 00063 ~SoundClip(); 00064 00069 bool isStream() const { 00070 return m_isstream; 00071 } 00072 00078 unsigned int countBuffers() const { 00079 return m_buffervec.at(0)->usedbufs; 00080 } 00081 00085 ALuint* getBuffers(unsigned int streamid = 0) const { 00086 return m_buffervec.at(streamid)->buffers; 00087 } 00088 00092 unsigned int beginStreaming(); 00093 00098 void acquireStream(unsigned int streamid); 00099 00103 bool setStreamPos(unsigned int streamid, SoundPositionType type, float value); 00104 00107 float getStreamPos(unsigned int streamid, SoundPositionType type) const; 00108 00114 bool getStream(unsigned int streamid, ALuint buffer); 00115 00118 void quitStreaming(unsigned int streamid); 00119 00120 //void addRef() { 00121 // m_refcount++; 00122 //} 00123 //void decRef() { 00124 // m_refcount--; 00125 //} 00126 // unsigned int getRefCount() { 00127 // return m_refcount; 00128 // } 00129 00132 SoundDecoder* getDecoder() const { 00133 return m_decoder; 00134 } 00135 00136 private: 00137 //unsigned int m_refcount; // Reference count of that soundclip 00138 bool m_isstream; // is stream? 00139 SoundDecoder* m_decoder; // attached decoder 00140 bool m_deletedecoder; // when loadFromDecoder-method is used, decoder shouldn't be deleted 00141 std::vector<SoundBufferEntry*> m_buffervec; 00142 }; 00143 } 00144 00145 #endif