mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
ensure silent channels get freed
This commit is contained in:
parent
ab11912f93
commit
0a142265cc
1 changed files with 26 additions and 12 deletions
|
@ -58,6 +58,21 @@ static int snd_scaletable[32][256];
|
||||||
|
|
||||||
/* CHANNEL MIXING */
|
/* CHANNEL MIXING */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
advance_channel (channel_t *ch, int count, unsigned int ltime)
|
||||||
|
{
|
||||||
|
if (!count || ltime >= ch->end) {
|
||||||
|
if (ch->sfx->loopstart != (unsigned int) -1) {
|
||||||
|
ch->pos = ch->sfx->loopstart;
|
||||||
|
ch->end = ltime + ch->sfx->length - ch->pos;
|
||||||
|
} else { // channel just stopped
|
||||||
|
ch->done = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SND_PaintChannels (unsigned int endtime)
|
SND_PaintChannels (unsigned int endtime)
|
||||||
{
|
{
|
||||||
|
@ -82,13 +97,20 @@ SND_PaintChannels (unsigned int endtime)
|
||||||
for (i = 0; i < snd_total_channels; i++, ch++) {
|
for (i = 0; i < snd_total_channels; i++, ch++) {
|
||||||
if (!ch->sfx)
|
if (!ch->sfx)
|
||||||
continue;
|
continue;
|
||||||
if (ch->stop) {
|
if (ch->stop || ch->done) {
|
||||||
if (!ch->done)
|
if (!ch->done)
|
||||||
ch->done = 1; // acknowledge stopped signal
|
ch->done = 1; // acknowledge stopped signal
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!ch->leftvol && !ch->rightvol)
|
if (!ch->leftvol && !ch->rightvol) {
|
||||||
|
ltime = snd_paintedtime;
|
||||||
|
if (ch->end < end)
|
||||||
|
count = ch->end - ltime;
|
||||||
|
else
|
||||||
|
count = end - ltime;
|
||||||
|
advance_channel (ch, count, ltime);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
sc = ch->sfx->getbuffer (ch->sfx);
|
sc = ch->sfx->getbuffer (ch->sfx);
|
||||||
if (!sc)
|
if (!sc)
|
||||||
continue;
|
continue;
|
||||||
|
@ -111,16 +133,8 @@ SND_PaintChannels (unsigned int endtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if at end of loop, restart
|
// if at end of loop, restart
|
||||||
if (!count || ltime >= ch->end) {
|
if (!advance_channel (ch, count, ltime))
|
||||||
if (ch->sfx->loopstart != (unsigned int) -1) {
|
break;
|
||||||
ch->pos = ch->sfx->loopstart;
|
|
||||||
ch->end = ltime + ch->sfx->length - ch->pos;
|
|
||||||
break;
|
|
||||||
} else { // channel just stopped
|
|
||||||
ch->done = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue