X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=snd_mix.c;h=6bec880eae3974665dcc699feff687b8a84779fb;hb=e20c1dc4aa543c277fdac4952d5cf4ab90de7026;hp=cc425bac6105cedbd99d4600954a3b58f4f2cc39;hpb=a3ea93578d5055b8b3b37507695e598a61404db3;p=xonotic%2Fdarkplaces.git diff --git a/snd_mix.c b/snd_mix.c index cc425bac..6bec880e 100644 --- a/snd_mix.c +++ b/snd_mix.c @@ -510,6 +510,8 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes) continue; if (!sfx->total_length) continue; + if (sfx->total_length > 1<<30) + Sys_Error("S_MixToBuffer: sfx corrupt\n"); ltime = 0; if (ch->pos < 0) @@ -525,15 +527,15 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes) // paint up to end of buffer or of input, whichever is lower count = sfx->total_length - ch->pos; count = bound(0, count, (int)frames - ltime); + // mix the remaining samples if (count) { SND_PaintChannel (ch, paintbuffer + ltime, count); ch->pos += count; ltime += count; } - // if at end of sfx, loop or stop the channel - if (ch->pos >= (int)sfx->total_length) + else { if (sfx->loopstart < sfx->total_length) ch->pos = sfx->loopstart; @@ -541,7 +543,7 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes) ch->pos = 0; else { - S_StopChannel (ch - channels, false); + S_StopChannel (ch - channels, false, false); break; } }