use ch->sfx in one place only. doesn't really fix anything though.

This commit is contained in:
Bill Currie 2007-03-27 03:49:42 +00:00 committed by Jeff Teunissen
parent 72a1aeb74b
commit 5d73a80887
1 changed files with 12 additions and 11 deletions

View File

@ -59,18 +59,18 @@ static int snd_scaletable[32][256];
/* CHANNEL MIXING */ /* CHANNEL MIXING */
static inline int static inline int
check_channel_end (channel_t *ch, int count, unsigned ltime) check_channel_end (channel_t *ch, sfx_t *sfx, int count, unsigned ltime)
{ {
if (count <= 0 || ltime >= ch->end) { if (count <= 0 || ltime >= ch->end) {
if (ch->sfx->loopstart != (unsigned) -1) { if (sfx->loopstart != (unsigned) -1) {
ch->pos = ch->sfx->loopstart; ch->pos = sfx->loopstart;
ch->end = ltime + ch->sfx->length - ch->pos; ch->end = ltime + sfx->length - ch->pos;
} else { // channel just stopped } else { // channel just stopped
ch->done = 1; ch->done = 1;
return 0; return 1;
} }
} }
return 1; return 0;
} }
static inline void static inline void
@ -109,6 +109,7 @@ SND_PaintChannels (unsigned endtime)
unsigned end, ltime; unsigned end, ltime;
int i, count; int i, count;
channel_t *ch; channel_t *ch;
sfx_t *sfx;
sfxbuffer_t *sc; sfxbuffer_t *sc;
// clear the paint buffer // clear the paint buffer
@ -125,18 +126,18 @@ SND_PaintChannels (unsigned endtime)
// paint in the channels. // paint in the channels.
ch = snd_channels; ch = snd_channels;
for (i = 0; i < snd_total_channels; i++, ch++) { for (i = 0; i < snd_total_channels; i++, ch++) {
if (!ch->sfx) if (!(sfx = ch->sfx))
continue; continue;
if (ch->stop || ch->done) { if (ch->stop || ch->done) {
ch->done = 1; // acknowledge stopped signal ch->done = 1; // acknowledge stopped signal
continue; continue;
} }
sc = ch->sfx->getbuffer (ch->sfx); sc = sfx->getbuffer (sfx);
if (!sc) if (!sc) // something went wrong with the sfx
continue; continue;
if (!ch->end) if (!ch->end)
ch->end = snd_paintedtime + ch->sfx->length; ch->end = snd_paintedtime + sfx->length;
ltime = snd_paintedtime; ltime = snd_paintedtime;
@ -151,7 +152,7 @@ SND_PaintChannels (unsigned endtime)
ltime += count; ltime += count;
} }
if (!check_channel_end (ch, count, ltime)) if (check_channel_end (ch, sfx, count, ltime))
break; break;
} }
} }