"L. Spiro Engine"
|
00001 00045 #ifndef __LSS_SOUNDBUFFER_H__ 00046 #define __LSS_SOUNDBUFFER_H__ 00047 00048 #include "../LSSSoundLib.h" 00049 #include "Allocator/LSTLAllocator.h" 00050 #include <cassert> 00051 00052 namespace lss { 00053 00089 class CSoundBuffer { 00090 friend class CSoundManager; 00091 friend class CStaticSoundSource; // It needs access to m_uiAlBufferId, which cannot be 00092 // exposed via accessors because its type and meaning 00093 // are specific to OpenAL. 00094 friend class CStreamingSoundSource; 00095 00096 public : 00097 // == Various constructors. 00098 virtual LSE_CALLCTOR ~CSoundBuffer(); 00099 00100 00101 // == Enumerations. 00105 enum LSS_ERROR { 00106 LSS_E_INVALID_BUFFER = 0, 00107 }; 00108 00109 00110 // == Functions. 00116 LSUINT32 LSE_CALL GetId() const; 00117 00121 LSVOID LSE_CALL IncRef() const; 00122 00126 LSVOID LSE_CALL DecRef() const; 00127 00133 LSUINT32 LSE_CALL GetRef() const; 00134 00140 LSUINT64 LSE_CALL GetLengthInMicros() const; 00141 00153 virtual LSBOOL LSE_CALL CanSoftUnload() const; 00154 00155 00156 protected : 00157 // == Various constructors. 00158 LSE_CALLCTOR CSoundBuffer( const LSUINT8 * _pui8Data, LSUINT32 _ui32Length, 00159 LSUINT32 _ui32Freq, LSUINT32 _ui32Bits, LSUINT32 _ui32Channels, CAllocator * _paAllocator, LSBOOL _bRetain, LSUINTPTR _uiptrUserData ); 00160 00161 00162 // == Enumerations. 00163 #ifdef LSS_USEOPENAL 00164 // An invalid OpenAL buffer ID. Used internally. 00165 enum { 00166 LSS_INVALID_BUFFER = 0, 00167 }; 00168 #endif // #ifdef LSS_USEOPENAL 00169 00170 00171 // == Members. 00172 // Length of this buffer in microseconds. 00173 LSUINT64 m_ui64BufferTime; 00174 00175 // Our buffered data in PCM format. 00176 LSUINT8 * m_pui8Data; 00177 00178 // Size of the data. 00179 LSUINT32 m_ui32Size; 00180 00181 // Do we retain the data after sending it to the hardware? 00182 LSBOOL m_bRetain; 00183 00184 // Frequency in Hz. 00185 LSUINT32 m_ui32Freq; 00186 00187 // Bit depth of buffer. 00188 LSUINT16 m_ui16BitDepth; 00189 00190 // Number of channels. 00191 LSUINT16 m_ui16Channels; 00192 00193 // Allocator we use. May not be NULL. 00194 CAllocator * m_paAllocator; 00195 00196 // Our ID. 00197 LSUINT32 m_ui32Id; 00198 00199 // Reference count. 00200 mutable LSINT32 m_i32Ref; 00201 00202 // ID counter. 00203 static LSUINT32 m_ui32MasterId; 00204 00205 #ifdef LSS_USEOPENAL 00206 // The OpenAL ID for this buffer. 00207 // Created with ::alGenBuffers(). 00208 ALuint m_uiAlBufferId; 00209 00210 #endif // #ifdef LSS_USEOPENAL 00211 00212 private : 00213 // == Functions. 00222 virtual LSBOOL LSE_CALL DeviceActivated(); 00223 00229 virtual LSVOID LSE_CALL DeviceWillClose(); 00230 00241 virtual LSBOOL LSE_CALL GetOriginalData(); 00242 }; 00243 00244 } // namespace lss 00245 00246 #endif // __LSS_SOUNDBUFFER_H__