MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / play

Method play

Engine/source/sfx/sfxVoice.cpp:178–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176//-----------------------------------------------------------------------------
177
178void SFXVoice::play( bool looping )
179{
180 AssertFatal( mBuffer != NULL, "SFXVoice::play() - no buffer" );
181 using namespace SFXInternal;
182
183 // For streaming, check whether we have played previously.
184 // If so, reset the buffer's stream.
185
186 if( mBuffer->isStreaming() &&
187 mStatus == SFXStatusStopped )
188 _resetStream( 0 );
189
190 // Now switch state.
191
192 while( mStatus != SFXStatusPlaying &&
193 mStatus != SFXStatusBlocked )
194 {
195 if( !mBuffer->isReady() &&
196 ( dCompareAndSwap( ( U32& ) mStatus, SFXStatusNull, SFXStatusBlocked ) ||
197 dCompareAndSwap( ( U32& ) mStatus, SFXStatusStopped, SFXStatusBlocked ) ||
198 dCompareAndSwap( ( U32& ) mStatus, SFXStatusPaused, SFXStatusBlocked ) ) )
199 {
200 #ifdef DEBUG_SPEW
201 Platform::outputDebugString( "[SFXVoice] Wanted to start playback but buffer isn't ready" );
202 #endif
203
204 break;
205 }
206
207 else if( dCompareAndSwap( ( U32& ) mStatus, SFXStatusNull, SFXStatusTransition ) ||
208 dCompareAndSwap( ( U32& ) mStatus, SFXStatusStopped, SFXStatusTransition ) ||
209 dCompareAndSwap( ( U32& ) mStatus, SFXStatusPaused, SFXStatusTransition ) )
210 {
211 _play();
212 dCompareAndSwap( ( U32& ) mStatus, SFXStatusTransition, SFXStatusPlaying );
213
214 #ifdef DEBUG_SPEW
215 Platform::outputDebugString( "[SFXVoice] Started playback" );
216 #endif
217
218 break;
219 }
220 }
221}
222
223//-----------------------------------------------------------------------------
224

Callers 12

openMethod · 0.45
updateSoundMethod · 0.45
ea_updateMethod · 0.45
ea_updateMethod · 0.45
_execInsnMethod · 0.45
_playMethod · 0.45
_updateMethod · 0.45
_allocVoiceMethod · 0.45
_playMethod · 0.45
playOnceMethod · 0.45
sfxSystem.cppFile · 0.45
updateMethod · 0.45

Calls 3

dCompareAndSwapFunction · 0.50
isStreamingMethod · 0.45
isReadyMethod · 0.45

Tested by

no test coverage detected