X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=snd_bsd.c;h=923d6fc8c119b3d6c859c75ce411bf2b92139ccd;hb=e80a362bdb11a1192b828defe4ecc6953a4b8dbe;hp=caa7ee0c54c7fe31c3a540ff896e83e4ab38522b;hpb=6824d8ddc8a43cae0609be5bbe8bee01fa1a4225;p=xonotic%2Fdarkplaces.git diff --git a/snd_bsd.c b/snd_bsd.c index caa7ee0c..923d6fc8 100644 --- a/snd_bsd.c +++ b/snd_bsd.c @@ -38,7 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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) @@ -111,11 +110,11 @@ qboolean SNDDMA_Init (void) (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; } @@ -123,7 +122,7 @@ int SNDDMA_GetDMAPos (void) { audio_info_t info; - if (!snd_inited) + if (!shm) return 0; if (ioctl (audio_fd, AUDIO_GETINFO, &info) < 0) @@ -138,12 +137,8 @@ int SNDDMA_GetDMAPos (void) void SNDDMA_Shutdown (void) { - if (snd_inited) - { - close (audio_fd); - audio_fd = -1; - snd_inited = false; - } + close (audio_fd); + audio_fd = -1; } /* @@ -162,7 +157,7 @@ void SNDDMA_Submit (void) int idx; int stop = paintedtime; - if (!snd_inited) + if (!shm) return; if (paintedtime < wbufp)