size = sfx->memsize;
format = sfx->fetcher->getfmt(sfx);
Con_Printf ("%c%c%c%c(%2db, %6s) %8i : %s\n",
- (sfx->loopstart >= 0) ? 'L' : ' ',
+ (sfx->loopstart < sfx->total_length) ? 'L' : ' ',
(sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ',
(sfx->locks > 0) ? 'K' : ' ',
(sfx->flags & SFXFLAG_PERMANENTLOCK) ? 'P' : ' ',
continue;
// don't override looped sounds
- if ((ch->flags & CHANNELFLAG_FORCELOOP) || ch->sfx->loopstart >= 0)
+ if ((ch->flags & CHANNELFLAG_FORCELOOP) || ch->sfx->loopstart < ch->sfx->total_length)
continue;
life_left = ch->sfx->total_length - ch->pos;
// If it's a static sound
if (isstatic)
{
- if (sfx->loopstart == -1)
+ if (sfx->loopstart >= sfx->total_length)
Con_DPrintf("Quake compatibility warning: Static sound \"%s\" is not looped\n", sfx->name);
target_chan->dist_mult = attenuation / (64.0f * snd_soundradius.value);
}
// freed at level change by S_ServerSounds.
unsigned int flags; // cf SFXFLAG_* defines
- int loopstart; // in sample frames. -1 if not looped
- int total_length; // in sample frames
+ unsigned int loopstart; // in sample frames. equals total_length if not looped
+ unsigned int total_length; // in sample frames
const snd_fetcher_t *fetcher;
void *fetcher_data; // Per-sfx data for the sound fetching functions
};
{
sfx_t *sfx;
unsigned int ltime;
- int count;
+ unsigned int count;
sfx = ch->sfx;
if (sfx == NULL)
if (ch->pos < 0)
{
count = -ch->pos;
- count = min(count, (int)(partialend - ltime));
+ count = min(count, partialend - ltime);
ch->pos += count;
ltime += count;
}
{
// paint up to end of buffer or of input, whichever is lower
count = sfx->total_length - ch->pos;
- count = bound(0, count, (int)(partialend - ltime));
+ count = bound(0, count, partialend - ltime);
if (count)
{
- SND_PaintChannel (ch, (unsigned int)count);
+ SND_PaintChannel (ch, count);
ch->pos += count;
ltime += count;
}
// if at end of sfx, loop or stop the channel
- if (ch->pos >= sfx->total_length)
+ if (ch->pos >= (int)sfx->total_length)
{
- if (sfx->loopstart >= 0 || (ch->flags & CHANNELFLAG_FORCELOOP))
- ch->pos = bound(0, sfx->loopstart, (int)sfx->total_length - 1);
+ if (sfx->loopstart < sfx->total_length)
+ ch->pos = sfx->loopstart;
+ else if (ch->flags & CHANNELFLAG_FORCELOOP)
+ ch->pos = 0;
else
{
S_StopChannel (ch - channels);
sfx->fetcher_data = per_sfx;
sfx->fetcher = &ogg_fetcher;
- sfx->loopstart = -1;
sfx->flags |= SFXFLAG_STREAMED;
sfx->total_length = (int)((size_t)len / (per_sfx->format.channels * 2) * ((double)snd_renderbuffer->format.speed / per_sfx->format.speed));
+ sfx->loopstart = sfx->total_length;
}
else
{
sfx->total_length = sb->nbframes;
sfx->memsize += sb->maxframes * sb->format.channels * sb->format.width + sizeof (*sb) - sizeof (sb->samples);
- sfx->loopstart = -1;
+ sfx->loopstart = sfx->total_length;
sfx->flags &= ~SFXFLAG_STREAMED;
qov_clear (&vf);
sfx->memsize += sb->maxframes * sb->format.channels * sb->format.width + sizeof (*sb) - sizeof (sb->samples);
if (info.loopstart < 0)
- sfx->loopstart = -1;
+ sfx->loopstart = sfx->total_length;
else
sfx->loopstart = (double)info.loopstart * (double)snd_renderbuffer->format.speed / (double)sb->format.speed;
+ sfx->loopstart = min(sfx->loopstart, sfx->total_length);
sfx->flags &= ~SFXFLAG_STREAMED;
Mem_Free (data);