| 176 | //----------------------------------------------------------------------------- |
| 177 | |
| 178 | void 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 |
no test coverage detected