X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=snd_main.c;h=0bd242cc0940090cdae61851fcb5ece2383b1993;hb=0732f3fb08b62b1d907235222d5ea9daf00641ca;hp=f2a6d5973f23356f4f0bc806db7e1e72064ca243;hpb=0350e62575cbc75a3e20d94c4dabb2b837d99a1a;p=xonotic%2Fdarkplaces.git diff --git a/snd_main.c b/snd_main.c index f2a6d597..0bd242cc 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1476,17 +1476,18 @@ void S_StopChannel (unsigned int channel_ind, qboolean lockmutex) if (channel_ind >= total_channels) return; + // we have to lock an audio mutex to prevent crashes if an audio mixer + // thread is currently mixing this channel + // the SndSys_LockRenderBuffer function uses such a mutex in + // threaded sound backends + if (lockmutex && !simsound) + SndSys_LockRenderBuffer(); + ch = &channels[channel_ind]; if (ch->sfx != NULL) { sfx_t *sfx = ch->sfx; - // we have to lock an audio mutex to prevent crashes if an audio mixer - // thread is currently mixing this channel - // the SndSys_LockRenderBuffer function uses such a mutex in - // threaded sound backends - if (lockmutex) - SndSys_LockRenderBuffer(); if (sfx->fetcher != NULL) { snd_fetcher_endsb_t fetcher_endsb = sfx->fetcher->endsb; @@ -1499,9 +1500,9 @@ void S_StopChannel (unsigned int channel_ind, qboolean lockmutex) ch->fetcher_data = NULL; ch->sfx = NULL; - if (lockmutex) - SndSys_UnlockRenderBuffer(); } + if (lockmutex && !simsound) + SndSys_UnlockRenderBuffer(); } @@ -1548,18 +1549,18 @@ void S_StopAllSounds (void) // stop CD audio because it may be using a faketrack CDAudio_Stop(); - for (i = 0; i < total_channels; i++) - S_StopChannel (i, true); - - total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics - memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); - - // Mute the contents of the submittion buffer if (simsound || SndSys_LockRenderBuffer ()) { int clear; size_t memsize; + for (i = 0; i < total_channels; i++) + S_StopChannel (i, false); + + total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics + memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); + + // Mute the contents of the submittion buffer clear = (snd_renderbuffer->format.width == 1) ? 0x80 : 0; memsize = snd_renderbuffer->maxframes * snd_renderbuffer->format.width * snd_renderbuffer->format.channels; memset(snd_renderbuffer->ring, clear, memsize);