| 376 | //----------------------------------------------------------------------------- |
| 377 | |
| 378 | bool SFXController::_execInsn() |
| 379 | { |
| 380 | bool endUpdate = false; |
| 381 | Insn& insn = mInsns[ mIp ]; |
| 382 | |
| 383 | switch( insn.mOpcode ) |
| 384 | { |
| 385 | case OP_Delay: |
| 386 | { |
| 387 | if( Platform::getVirtualMilliseconds() < mDelayEndTime ) |
| 388 | endUpdate = true; |
| 389 | else |
| 390 | _advanceIp(); |
| 391 | break; |
| 392 | } |
| 393 | |
| 394 | case OP_Play: |
| 395 | { |
| 396 | SFXPlayList* playList = getPlayList(); |
| 397 | SFXTrack* track = playList->getTrackProfile(insn.mSlotIndex); |
| 398 | |
| 399 | // Handle existing sources playing on this slot and find |
| 400 | // whether we need to start a new source. |
| 401 | // |
| 402 | // Go through the list top-down so we can push sources we re-use |
| 403 | // to the top of the list. A side-effect of doing it this way is |
| 404 | // that the order of the sources that are preserved gets reversed, |
| 405 | // i.e. older sources will end up higher up the stack. |
| 406 | |
| 407 | bool startNew = true; |
| 408 | SFXPlayList::EReplayMode replayMode = playList->getSlots().mReplayMode[ insn.mSlotIndex ]; |
| 409 | if( replayMode != SFXPlayList::REPLAY_IgnorePlaying ) |
| 410 | for( S32 i = mSources.size() - 1; i >= 0; -- i ) |
| 411 | { |
| 412 | Source& source = mSources[ i ]; |
| 413 | if( source.mSlotIndex != insn.mSlotIndex ) |
| 414 | continue; |
| 415 | |
| 416 | // If the play-once source has expired, remove the entry |
| 417 | // and go on. |
| 418 | |
| 419 | if( source.mPtr == NULL ) |
| 420 | { |
| 421 | mSources.erase( i ); |
| 422 | ++ i; |
| 423 | continue; |
| 424 | } |
| 425 | |
| 426 | // Decide what to do with the still-playing source. |
| 427 | |
| 428 | if( replayMode == SFXPlayList::REPLAY_RestartPlaying |
| 429 | || replayMode == SFXPlayList::REPLAY_KeepPlaying ) |
| 430 | { |
| 431 | // Restart the source or keep playing it. |
| 432 | // Either way, move it to the top of the stack. |
| 433 | |
| 434 | startNew = false; |
| 435 |
nothing calls this directly
no test coverage detected