"L. Spiro Engine"
|
00001 00017 #ifndef __LSS_STREAMINGSOUNDSOURCE_H__ 00018 #define __LSS_STREAMINGSOUNDSOURCE_H__ 00019 00020 #include "../LSSSoundLib.h" 00021 #include "LSSStaticSoundSource.h" 00022 #include "LSSStreamingSoundSourceStreamer.h" 00023 #include "Vector/LSTLVectorPoD.h" 00024 00025 00026 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00027 // MACROS 00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00029 // The length, in microseconds of the buffers used for streaming. 00030 #ifndef LSS_STREAMING_BUFFER_SIZE 00031 #define LSS_STREAMING_BUFFER_SIZE ((1ULL * 1000000ULL) / 2ULL) 00032 #endif // #ifndef LSS_STREAMING_BUFFER_SIZE 00033 00034 namespace lss { 00035 00043 class CStreamingSoundSource : public CStaticSoundSource { 00044 public : 00045 // == Various constructors. 00046 LSE_CALLCTOR CStreamingSoundSource( LSUINT32 _ui32Id ); 00047 virtual LSE_CALLCTOR ~CStreamingSoundSource(); 00048 00049 // == Functions. 00055 virtual LSS_SOUND_SOURCE LSE_CALL GetType() const; 00056 00062 virtual LSBOOL LSE_CALL Static() const; 00063 00070 virtual LSVOID LSE_CALL SetBuffer( const CSoundBuffer * _psbBuffer ); 00071 00079 LSBOOL LSE_CALL CreateStream( const IStreamingSoundSourceStreamer * _pssssSource, 00080 CAllocator * _paAllocator ); 00081 00085 LSVOID LSE_CALL Reset(); 00086 00093 virtual LSVOID LSE_CALL Tick( LSUINT64 _ui64TimeSinceLastUpdate ); 00094 00105 virtual LSBOOL LSE_CALL Play( LSUINT32 _ui32LoopCount ); 00106 00112 const IStreamingSoundSourceStreamer * LSE_CALL GetStreamer() const; 00113 00123 virtual LSBOOL LSE_CALL CanSoftReset() const; 00124 00125 00126 protected : 00127 // == Types. 00131 typedef struct LSS_STREAMING_BUFFER { 00135 CSoundBuffer * psbBuffer; 00136 00140 LSUINT64 ui64StartTime; 00141 00145 LSUINT64 ui64Length; 00146 00150 LSBOOL bUsed; 00151 } * LPLSS_STREAMING_BUFFER, * const LPCLSS_STREAMING_BUFFER; 00152 00156 typedef CVectorPoD<LSS_STREAMING_BUFFER> LSS_STREAMING_BUFFER_LIST, * LPLSS_STREAMING_BUFFER_LIST, * const LPCLSS_STREAMING_BUFFER_LIST; 00157 00158 00159 // == Members. 00163 LSS_STREAMING_BUFFER_LIST m_sblBuffers; 00164 00168 CAllocator * m_paAllocator; 00169 00170 // The source of audio data for our stream. 00171 const IStreamingSoundSourceStreamer * m_pssssSource; 00172 00173 // The number of bytes in each buffer. 00174 LSUINT64 m_ui64BufferSize; 00175 00176 // How far into the sound have we queued? In microseconds. 00177 LSUINT64 m_ui64Queued; 00178 00179 // Is the device activated? 00180 LSBOOL m_bHaveDevice; 00181 00182 00183 // == Functions. 00189 LSVOID LSE_CALL SetSource( const IStreamingSoundSourceStreamer * _pssssSource ); 00190 00194 LSVOID LSE_CALL CheckQueue(); 00195 00199 LSVOID LSE_CALL CheckUnqueue(); 00200 00206 LSUINT32 LSE_CALL GetOldestBufferIndex() const; 00207 00213 LSUINT32 LSE_CALL GetFreeBuffer() const; 00214 00223 LSBOOL LSE_CALL Buffer( LSUINT64 _ui64From, LSUINT64 _ui64Length ); 00224 00230 LSVOID LSE_CALL UnBuffer( LSUINT32 _ui32Index ); 00231 00240 virtual LSBOOL LSE_CALL DeviceActivated(); 00241 00247 virtual LSVOID LSE_CALL DeviceWillClose(); 00248 00249 00250 private : 00251 typedef CStaticSoundSource Parent; 00252 }; 00253 00254 } // namespace lss 00255 00256 #endif // __LSS_STREAMINGSOUNDSOURCE_H__