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

Function UpdateLoopingSounds

code/client/snd_dma.cpp:3248–3431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3246}
3247
3248void UpdateLoopingSounds()
3249{
3250 int i,j;
3251 ALuint source;
3252 channel_t *ch;
3253 loopSound_t *loop;
3254 float pos[3];
3255
3256 // First check to see if any of the looping sounds are already playing at the correct positions
3257 ch = s_channels + 1;
3258 for (i = 1; i < s_numChannels; i++, ch++)
3259 {
3260 if (ch->bLooping && s_channels[i].bPlaying)
3261 {
3262 for (j = 0; j < numLoopSounds; j++)
3263 {
3264 loop = &loopSounds[j];
3265
3266 // If this channel is playing the right sound effect at the right position then mark this channel and looping sound
3267 // as processed
3268 if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx) )
3269 {
3270 if ( (loop->origin[0] == listener_pos[0]) && (loop->origin[1] == -listener_pos[2])
3271 && (loop->origin[2] == listener_pos[1]) )
3272 {
3273 // Assume that this sound is head relative
3274 if (!loop->bRelative)
3275 {
3276 // Set position to 0,0,0 and turn on Head Relative Mode
3277 float pos[3];
3278 pos[0] = 0.f;
3279 pos[1] = 0.f;
3280 pos[2] = 0.f;
3281
3282 alSourcefv(s_channels[i].alSource, AL_POSITION, pos);
3283 alSourcei(s_channels[i].alSource, AL_SOURCE_RELATIVE, AL_TRUE);
3284 loop->bRelative = qtrue;
3285 }
3286
3287 // Make sure Gain is set correctly
3288 if (ch->master_vol != loop->volume)
3289 {
3290 ch->master_vol = loop->volume;
3291 alSourcef(s_channels[i].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
3292 }
3293
3294 ch->bProcessed = true;
3295 loop->bProcessed = qtrue;
3296 }
3297 else if ((loop->bProcessed == false) && (ch->thesfx == loop->sfx) && (!memcmp(ch->origin, loop->origin, sizeof(ch->origin))))
3298 {
3299 // Match !
3300 ch->bProcessed = true;
3301 loop->bProcessed = qtrue;
3302
3303 // Make sure Gain is set correctly
3304 if (ch->master_vol != loop->volume)
3305 {

Callers 1

snd_dma.cppFile · 0.70

Calls 2

UpdateEAXBufferFunction · 0.70
S_PickChannelFunction · 0.70

Tested by

no test coverage detected