WAV_FetchSound
====================
*/
-static const snd_buffer_t* WAV_FetchSound (channel_t* ch, unsigned int *start, unsigned int nbsampleframes)
+static const snd_buffer_t* WAV_FetchSound (void *sfxfetcher, void **chfetcherpointer, unsigned int *start, unsigned int nbsampleframes)
{
*start = 0;
- return (snd_buffer_t *)ch->sfx->fetcher_data;
+ return (snd_buffer_t *)sfxfetcher;
}
/*
WAV_FreeSfx
====================
*/
-static void WAV_FreeSfx (sfx_t* sfx)
+static void WAV_FreeSfx (void *sfxfetcherdata)
{
- snd_buffer_t* sb = (snd_buffer_t *)sfx->fetcher_data;
-
+ snd_buffer_t* sb = (snd_buffer_t *)sfxfetcherdata;
// Free the sound buffer
- sfx->memsize -= (sb->maxframes * sb->format.channels * sb->format.width) + sizeof (*sb) - sizeof (sb->samples);
Mem_Free(sb);
-
- sfx->fetcher_data = NULL;
- sfx->fetcher = NULL;
}
/*
return false;
}
- Con_DPrintf ("Loading WAV file \"%s\"\n", filename);
+ if (developer_loading.integer >= 2)
+ Con_Printf ("Loading WAV file \"%s\"\n", filename);
info = GetWavinfo (sfx->name, data, (int)filesize);
if (info.channels < 1 || info.channels > 2) // Stereo sounds are allowed (intended for music)
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 = (unsigned int) ((double)info.loopstart * (double)sb->format.speed / (double)info.rate);
+ sfx->loopstart = min(sfx->loopstart, sfx->total_length);
sfx->flags &= ~SFXFLAG_STREAMED;
Mem_Free (data);