]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_sdl.c
eliminated qbyte type, now uses unsigned char throughout the engine for this purpose
[xonotic/darkplaces.git] / snd_sdl.c
index 45b359ac716467c5e0a043cef011d69a5918d9ea..dbeb3ced0350067b7ac8fc723c5014bee5914a0f 100644 (file)
--- a/snd_sdl.c
+++ b/snd_sdl.c
@@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 #include "quakedef.h"
+#include "snd_main.h"
 #include <SDL.h>
 
 /*
@@ -38,7 +39,6 @@ typedef struct AudioState_s
 } AudioState;
 
 
-extern mempool_t *snd_mempool;
 static AudioState       as;
 
 static void Buffer_Callback(void *userdata, Uint8 *stream, int len);
@@ -86,16 +86,17 @@ qboolean SNDDMA_Init(void)
 
        // Init the SDL Audio subsystem
        if( SDL_InitSubSystem( SDL_INIT_AUDIO ) ) {
-               Con_SafePrint( "Initializing the SDL Audio subsystem failed!\n" );
+               Con_Print( "Initializing the SDL Audio subsystem failed!\n" );
                return false;
        }
 
        // Init the shm structure
        memset( (void*) shm, 0, sizeof(*shm) );
-       
+
        shm->format.channels = 2; //stereo
        shm->format.width = 2;
 
+// COMMANDLINEOPTION: SDL Sound: -sndspeed <hz> chooses 44100 hz, 22100 hz, or 11025 hz sound output rate
        i = COM_CheckParm( "-sndspeed" );
        if( i && i != ( com_argc - 1 ) )
                shm->format.speed = atoi( com_argv[ i+1 ] );
@@ -105,7 +106,7 @@ qboolean SNDDMA_Init(void)
        shm->samplepos = 0;
        shm->samples = AUDIO_SDL_SAMPLES * AUDIO_LOCALFACTOR;
        shm->bufferlength = shm->samples * shm->format.width;
-       shm->buffer = Mem_Alloc( snd_mempool, shm->bufferlength );
+       shm->buffer = (unsigned char *)Mem_Alloc( snd_mempool, shm->bufferlength );
 
        // Init the as structure
        as.buffer = shm->buffer;
@@ -116,21 +117,21 @@ qboolean SNDDMA_Init(void)
        // Init the SDL Audio subsystem
        spec.callback = Buffer_Callback;
        spec.channels = shm->format.channels;
-       spec.format = AUDIO_S16LSB;
+       spec.format = AUDIO_S16SYS;
        spec.freq = shm->format.speed;
        spec.userdata = NULL;
-       spec.samples = AUDIO_SDL_SAMPLES; 
-       
+       spec.samples = AUDIO_SDL_SAMPLES;
+
        if( SDL_OpenAudio( &spec, NULL ) ) {
-               Con_SafePrint( "Failed to open the audio device!\n" );
-               Con_DPrintf( 
+               Con_Print( "Failed to open the audio device!\n" );
+               Con_DPrintf(
                        "Audio Specification:\n"
                        "\tChannels  : %i\n"
                        "\tFormat    : %x\n"
                        "\tFrequency : %i\n"
-                       "\tBuffersize: %i Bytes(%i Samples)\n", 
+                       "\tBuffersize: %i Bytes(%i Samples)\n",
                        spec.channels, spec.format, spec.freq, shm->bufferlength , spec.samples );
-               Mem_Free( shm->buffer ); 
+               Mem_Free( shm->buffer );
                return false;
        }