| 810 | //----------------------------------------------------------------------------- |
| 811 | |
| 812 | void SFXController::_update() |
| 813 | { |
| 814 | Parent::_update(); |
| 815 | |
| 816 | SFXPlayList* playList = getPlayList(); |
| 817 | |
| 818 | // Check all sources against the current state setup and |
| 819 | // take appropriate actions. |
| 820 | |
| 821 | for( U32 i = 0; i < mSources.size(); ++ i ) |
| 822 | { |
| 823 | Source& source = mSources[ i ]; |
| 824 | |
| 825 | // If the source has already stopped playing, |
| 826 | // remove it. |
| 827 | |
| 828 | if( !source.mPtr ) |
| 829 | { |
| 830 | mSources.erase( i ); |
| 831 | -- i; |
| 832 | continue; |
| 833 | } |
| 834 | |
| 835 | if( !source.mState ) |
| 836 | continue; |
| 837 | |
| 838 | SFXPlayList::EStateMode stateMode = playList->getSlots().mStateMode[ mSources[ i ].mSlotIndex ]; |
| 839 | if( !source.mState->isActive() ) |
| 840 | { |
| 841 | if( source.mPtr->isPlaying() ) |
| 842 | { |
| 843 | // The source is playing in an incompatible state. |
| 844 | |
| 845 | if( stateMode == SFXPlayList::STATE_PauseInactive ) |
| 846 | source.mPtr->pause(); |
| 847 | else if( stateMode == SFXPlayList::STATE_StopInactive ) |
| 848 | { |
| 849 | source.mPtr->stop(); |
| 850 | mSources.erase( i ); |
| 851 | |
| 852 | -- i; |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | else |
| 857 | { |
| 858 | // Unpause a source that had its state become active again. |
| 859 | |
| 860 | if( source.mPtr->isPaused() && stateMode == SFXPlayList::STATE_PauseInactive ) |
| 861 | source.mPtr->play(); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | // Update interpreter. |
| 866 | |
| 867 | bool endUpdate = false; |
| 868 | while( !endUpdate ) |
| 869 | { |
nothing calls this directly
no test coverage detected