static const int tryrates[] = {44100, 22050, 11025, 8000};
static int audio_fd = -1;
-static qboolean snd_inited = false;
// TODO: allocate them in SNDDMA_Init, with a size depending on
// the sound format (enough for 0.5 sec of sound for instance)
(info.play.channels == 2) ? "stereo" : "mono",
info.play.sample_rate);
- shm->samples = sizeof (dma_buffer) / shm->format.width;
+ shm->sampleframes = sizeof (dma_buffer) / shm->format.width / shm->format.channels;
+ shm->samples = shm->sampleframes * shm->format.channels;
shm->samplepos = 0;
shm->buffer = dma_buffer;
- snd_inited = true;
return true;
}
{
audio_info_t info;
- if (!snd_inited)
+ if (!shm)
return 0;
if (ioctl (audio_fd, AUDIO_GETINFO, &info) < 0)
void SNDDMA_Shutdown (void)
{
- if (snd_inited)
- {
- close (audio_fd);
- audio_fd = -1;
- snd_inited = false;
- }
+ close (audio_fd);
+ audio_fd = -1;
}
/*
int idx;
int stop = paintedtime;
- if (!snd_inited)
+ if (!shm)
return;
if (paintedtime < wbufp)