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

Method _updateSources

Engine/source/sfx/sfxSystem.cpp:818–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816//-----------------------------------------------------------------------------
817
818void 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();

Callers

nothing calls this directly

Calls 12

getSavedStatusMethod · 0.80
erase_fastMethod · 0.80
getCapsMethod · 0.80
getVoiceCountMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
updateMethod · 0.45
getStatusMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getLastStatusMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected