]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_oss.c
optimized LoadTGA to have fast paths for all formats, rather than one unified loading...
[xonotic/darkplaces.git] / snd_oss.c
index b1503200b38221c84ecc082fe8ced46c6bf0aa0e..f50c321c58c03d2cd2aa7d6145091c72ce7575bc 100644 (file)
--- a/snd_oss.c
+++ b/snd_oss.c
@@ -34,9 +34,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "snd_main.h"
 
 int audio_fd;
-int snd_inited;
 
-static int tryrates[] = {44100, 22050, 11025, 8000};
+static int tryrates[] = {44100, 48000, 22050, 24000, 11025, 16000, 8000};
 
 qboolean SNDDMA_Init(void)
 {
@@ -54,7 +53,6 @@ qboolean SNDDMA_Init(void)
 #else
        format16bit = AFMT_S16_LE;
 #endif
-       snd_inited = 0;
 
        // open /dev/dsp, confirm capability to mmap, and get size of dma buffer
     audio_fd = open("/dev/dsp", O_RDWR);  // we have to open it O_RDWR for mmap
@@ -225,7 +223,6 @@ qboolean SNDDMA_Init(void)
 
        shm->samplepos = 0;
 
-       snd_inited = 1;
        return 1;
 }
 
@@ -234,14 +231,13 @@ int SNDDMA_GetDMAPos(void)
 
        struct count_info count;
 
-       if (!snd_inited) return 0;
+       if (!shm) return 0;
 
        if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &count)==-1)
        {
                perror("/dev/dsp");
                Con_Print("Uh, sound dead.\n");
-               close(audio_fd);
-               snd_inited = 0;
+               S_Shutdown();
                return 0;
        }
        shm->samplepos = count.ptr / shm->format.width;
@@ -252,19 +248,15 @@ int SNDDMA_GetDMAPos(void)
 void SNDDMA_Shutdown(void)
 {
        int tmp;
-       if (snd_inited)
-       {
-               // unmap the memory
-               munmap(shm->buffer, shm->bufferlength);
-               // stop the sound
-               tmp = 0;
-               ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
-               ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
-               // close the device
-               close(audio_fd);
-               audio_fd = -1;
-               snd_inited = 0;
-       }
+       // unmap the memory
+       munmap(shm->buffer, shm->bufferlength);
+       // stop the sound
+       tmp = 0;
+       ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+       ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+       // close the device
+       close(audio_fd);
+       audio_fd = -1;
 }
 
 /*