MCPcopy Create free account
hub / github.com/JACoders/OpenJK / S_AddAmbientLoopingSound

Function S_AddAmbientLoopingSound

code/client/snd_dma.cpp:1917–1956  ·  view source on GitHub ↗

================== S_AddAmbientLoopingSound ================== */

Source from the content-addressed store, hash-verified

1915==================
1916*/
1917void S_AddAmbientLoopingSound( const vec3_t origin, unsigned char volume, sfxHandle_t sfxHandle )
1918{
1919 /*const*/ sfx_t *sfx;
1920
1921 if ( !s_soundStarted || s_soundMuted ) {
1922 return;
1923 }
1924 if ( numLoopSounds >= MAX_LOOP_SOUNDS ) {
1925 return;
1926 }
1927
1928#ifdef USE_OPENAL
1929 if (s_UseOpenAL)
1930 {
1931 if (volume == 0)
1932 return;
1933 }
1934#endif
1935
1936 if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
1937 Com_Error( ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle );
1938 }
1939
1940 sfx = &s_knownSfx[ sfxHandle ];
1941 if (sfx->bInMemory == qfalse){
1942 S_memoryLoad(sfx);
1943 }
1944 SND_TouchSFX(sfx);
1945
1946 if ( !sfx->iSoundLengthInSamples ) {
1947 Com_Error( ERR_DROP, "%s has length 0", sfx->sSoundName );
1948 }
1949 VectorCopy( origin, loopSounds[numLoopSounds].origin );
1950 loopSounds[numLoopSounds].sfx = sfx;
1951 assert(!sfx->pMP3StreamHeader);
1952
1953 //TODO: Calculate the distance falloff
1954 loopSounds[numLoopSounds].volume = volume;
1955 numLoopSounds++;
1956}
1957
1958/*
1959==================

Callers 2

AS_PlayLocalSetFunction · 0.70
AS_PlayAmbientSetFunction · 0.70

Calls 4

VectorCopyFunction · 0.85
S_memoryLoadFunction · 0.70
SND_TouchSFXFunction · 0.70
Com_ErrorFunction · 0.50

Tested by

no test coverage detected