shm->format.channels = 2;
shm->samples = 32768;
shm->samplepos = 0;
- shm->buffer = Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width);
+ shm->buffer = (unsigned char *)Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width);
}
else
{
sound_started = true;
- Con_DPrintf("Sound sampling rate: %i\n", shm->format.speed);
+ Con_Printf("Sound format: %dHz, %d bit, %d channels\n", shm->format.speed,
+ shm->format.width * 8, shm->format.channels);
}
void S_Shutdown(void)
return sfx;
// Add a sfx_t struct for this sound
- sfx = Mem_Alloc (snd_mempool, sizeof (*sfx));
+ sfx = (sfx_t *)Mem_Alloc (snd_mempool, sizeof (*sfx));
memset (sfx, 0, sizeof(*sfx));
strlcpy (sfx->name, name, sizeof (sfx->name));
+ sfx->memsize = sizeof(*sfx);
sfx->next = known_sfx;
known_sfx = sfx;
*/
void S_FreeSfx (sfx_t *sfx, qboolean force)
{
+ unsigned int i;
+
// Never free a locked sfx unless forced
if (!force && (sfx->locks > 0 || (sfx->flags & SFXFLAG_PERMANENTLOCK)))
return;
}
}
+ // Stop all channels using this sfx
+ for (i = 0; i < total_channels; i++)
+ if (channels[i].sfx == sfx)
+ S_StopChannel (i);
+
// Free it
- Mem_FreePool (&sfx->mempool);
+ if (sfx->fetcher != NULL && sfx->fetcher->free != NULL)
+ sfx->fetcher->free (sfx);
Mem_Free (sfx);
}
if (sfx->fetcher != NULL)
{
- snd_fetcher_end_t fetcher_end = sfx->fetcher->end;
- if (fetcher_end != NULL)
- fetcher_end (ch);
+ snd_fetcher_endsb_t fetcher_endsb = sfx->fetcher->endsb;
+ if (fetcher_endsb != NULL)
+ fetcher_endsb (ch);
}
// Remove the lock it holds
memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
// Clear sound buffer
- pbuf = S_LockBuffer();
+ pbuf = (unsigned char *)S_LockBuffer();
if (pbuf != NULL)
{
int setsize = shm->samples * shm->format.width;
float vol;
int ambient_channel;
channel_t *chan;
- qbyte ambientlevels[NUM_AMBIENTS];
+ unsigned char ambientlevels[NUM_AMBIENTS];
if (ambient_level.value <= 0 || !cl.worldmodel || !cl.worldmodel->brush.AmbientSoundLevelsForPoint)
return;
{
if (sfx->fetcher != NULL)
{
- size = (int)sfx->mempool->totalsize;
+ size = (int)sfx->memsize;
total += size;
Con_Printf ("%c%c%c%c(%2db, %6s) %8i : %s\n",
(sfx->loopstart >= 0) ? 'L' : ' ',