| 816 | //----------------------------------------------------------------------------- |
| 817 | |
| 818 | void SFXSystem::_updateSources() |
| 819 | { |
| 820 | PROFILE_SCOPE( SFXSystem_UpdateSources ); |
| 821 | |
| 822 | SimSet* sources = Sim::getSFXSourceSet(); |
| 823 | if( !sources ) |
| 824 | return; |
| 825 | |
| 826 | // Check the status of the sources here once. |
| 827 | // |
| 828 | // NOTE: We do not use iterators in this loop because |
| 829 | // SFXControllers can add to the source list during the |
| 830 | // loop. |
| 831 | // |
| 832 | mStatNumPlaying = 0; |
| 833 | for( S32 i=0; i < sources->size(); i++ ) |
| 834 | { |
| 835 | SFXSource *source = dynamic_cast< SFXSource* >( sources->at( i ) ); |
| 836 | if ( source ) |
| 837 | { |
| 838 | source->update(); |
| 839 | if( source->getStatus() == SFXStatusPlaying ) |
| 840 | ++ mStatNumPlaying; |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | // First check to see if any play once sources have |
| 845 | // finished playback... delete them. |
| 846 | |
| 847 | for( SFXSourceVector::iterator iter = mPlayOnceSources.begin(); iter != mPlayOnceSources.end(); ) |
| 848 | { |
| 849 | SFXSource* source = *iter; |
| 850 | |
| 851 | if( source->getLastStatus() == SFXStatusStopped && |
| 852 | source->getSavedStatus() != SFXStatusPlaying ) |
| 853 | { |
| 854 | S32 index = iter - mPlayOnceSources.begin(); |
| 855 | |
| 856 | // Erase it from the vector first, so that onRemoveSource |
| 857 | // doesn't do it during cleanup and screw up our loop here! |
| 858 | mPlayOnceSources.erase_fast( iter ); |
| 859 | source->deleteObject(); |
| 860 | |
| 861 | iter = mPlayOnceSources.begin() + index; |
| 862 | continue; |
| 863 | } |
| 864 | |
| 865 | ++ iter; |
| 866 | } |
| 867 | |
| 868 | |
| 869 | if( mDevice ) |
| 870 | { |
| 871 | // Reassign buffers to the sounds (if voices are managed by |
| 872 | // us instead of by the device). |
| 873 | |
| 874 | if( !( mDevice->getCaps() & SFXDevice::CAPS_VoiceManagement ) ) |
| 875 | _assignVoices(); |
nothing calls this directly
no test coverage detected