MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / _assignVoices

Method _assignVoices

Engine/source/sfx/sfxSystem.cpp:901–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

899//-----------------------------------------------------------------------------
900
901void SFXSystem::_assignVoices()
902{
903 AssertFatal( getNumListeners() == 1, "SFXSystem::_assignVoices() - must only have a single listener" );
904 PROFILE_SCOPE( SFXSystem_AssignVoices );
905
906 mStatNumVoices = 0;
907 mStatNumCulled = 0;
908
909 if( !mDevice )
910 return;
911
912 // Sort the sources in the SFX source set by priority. This also
913 // updates each soures effective volume first.
914
915 _sortSounds( getListener() );
916
917 // We now make sure that the sources closest to the
918 // listener, the ones at the top of the source list,
919 // have a device buffer to play thru.
920
921 mStatNumCulled = 0;
922 for( SFXSoundVector::iterator iter = mSounds.begin(); iter != mSounds.end(); ++ iter )
923 {
924 SFXSound* sound = *iter;
925
926 // Non playing sources (paused or stopped) are at the
927 // end of the vector, so when i encounter one i know
928 // that nothing else in the vector needs buffer assignment.
929
930 if( !sound->isPlaying() )
931 break;
932
933 // If the source is outside it's max range we can
934 // skip it as well, so that we don't waste cycles
935 // setting up a buffer for something we won't hear.
936
937 if( sound->getAttenuatedVolume() <= 0.0f )
938 {
939 ++ mStatNumCulled;
940 continue;
941 }
942
943 // If the source has a voice then we can skip it.
944
945 if( sound->hasVoice() )
946 continue;
947
948 // Ok let the device try to assign a new voice for
949 // this source... this may fail if we're out of voices.
950
951 if( sound->_allocVoice( mDevice ) )
952 continue;
953
954 // The device couldn't assign a new voice, so we go through
955 // local priority sounds and try to steal a voice.
956
957 for( SFXSoundVector::iterator hijack = mSounds.end() - 1; hijack != iter; -- hijack )
958 {

Callers

nothing calls this directly

Calls 9

getAttenuatedVolumeMethod · 0.80
hasVoiceMethod · 0.80
_allocVoiceMethod · 0.80
_releaseVoiceMethod · 0.80
getVoiceCountMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
isPlayingMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected