]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_bsd.c
some work on SV_TestEntityPosition and entity unsticking, now only checks against...
[xonotic/darkplaces.git] / snd_bsd.c
index caa7ee0c54c7fe31c3a540ff896e83e4ab38522b..923d6fc8c119b3d6c859c75ce411bf2b92139ccd 100644 (file)
--- 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)