From 90849100fe68384f510aaaa0c4378d8fa931066b Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Thu, 23 Aug 2001 11:40:53 +0000 Subject: [PATCH] Build fixes, notably for snd_sdl.c. It segfaults on shutdown though :/ --- libs/audio/renderer/snd_dma.c | 3 --- libs/audio/targets/snd_disk.c | 7 ++++++- libs/audio/targets/snd_mme.c | 8 ++++---- libs/audio/targets/snd_sdl.c | 28 +++++++++++++++++++++++----- libs/audio/targets/snd_sun.c | 25 +++++++++++++++---------- libs/audio/targets/snd_win.c | 20 ++++++++------------ 6 files changed, 56 insertions(+), 35 deletions(-) diff --git a/libs/audio/renderer/snd_dma.c b/libs/audio/renderer/snd_dma.c index 863fc50d9..76d879078 100644 --- a/libs/audio/renderer/snd_dma.c +++ b/libs/audio/renderer/snd_dma.c @@ -96,9 +96,6 @@ int num_sfx; sfx_t *ambient_sfx[NUM_AMBIENTS]; -int desired_speed = 11025; -int desired_bits = 16; - int sound_started = 0; extern cvar_t *snd_loadas8bit; diff --git a/libs/audio/targets/snd_disk.c b/libs/audio/targets/snd_disk.c index 570698336..96115169e 100644 --- a/libs/audio/targets/snd_disk.c +++ b/libs/audio/targets/snd_disk.c @@ -53,6 +53,7 @@ static int snd_inited; VFile *snd_file; +int snd_blocked = 0; volatile dma_t sn; plugin_t plugin_info; @@ -131,12 +132,16 @@ SNDDMA_Submit (void) void SNDDMA_BlockSound (void) -{ +{ + ++snd_blocked; } void SNDDMA_UnblockSound (void) { + if (!snd_blocked) + return; + --snd_blocked; } plugin_t * diff --git a/libs/audio/targets/snd_mme.c b/libs/audio/targets/snd_mme.c index 030368721..f369f75b9 100644 --- a/libs/audio/targets/snd_mme.c +++ b/libs/audio/targets/snd_mme.c @@ -51,6 +51,7 @@ static qboolean snd_firsttime = true, snd_iswave; static int sample16; static int snd_sent, snd_completed; +int snd_blocked = 0; static HPSTR lpData; static LPWAVEHDR lpWaveHdr; @@ -78,11 +79,8 @@ S_BlockSound void S_BlockSound ( void ) { - snd_blocked++; - - if (snd_blocked == 1) { + if (++snd_blocked == 1) waveOutReset(hWaveOut); - } } @@ -94,6 +92,8 @@ S_UnblockSound void S_UnblockSound ( void ) { + if (!snd_blocked) + return; snd_blocked--; } diff --git a/libs/audio/targets/snd_sdl.c b/libs/audio/targets/snd_sdl.c index 0dd9b6ee5..7c8a8ae82 100644 --- a/libs/audio/targets/snd_sdl.c +++ b/libs/audio/targets/snd_sdl.c @@ -36,6 +36,7 @@ # include #endif +#include #include #include #include @@ -49,9 +50,10 @@ static dma_t the_shm; static int snd_inited; +int snd_blocked = 0; -extern int desired_speed; -extern int desired_bits; +int desired_speed = 11025; +int desired_bits = 16; plugin_t plugin_info; plugin_data_t plugin_info_data; @@ -77,7 +79,7 @@ paint_audio (void *unused, Uint8 * stream, int len) shm->samplepos += streamsamples; while (shm->samplepos >= shm->samples) shm->samplepos -= shm->samples; - SND_PaintChannels (*plugin_info_snd_output_data.soundtime + streamsamples); +// SND_PaintChannels (*plugin_info_snd_output_data.soundtime + streamsamples); if (shm->samplepos + streamsamples <= shm->samples) memcpy (stream, shm->buffer + sampleposbytes, len); @@ -91,6 +93,11 @@ paint_audio (void *unused, Uint8 * stream, int len) } } +void +SNDDMA_Init_Cvars (void) +{ +} + qboolean SNDDMA_Init (void) { @@ -98,6 +105,11 @@ SNDDMA_Init (void) snd_inited = 0; + if (SDL_Init (SDL_INIT_AUDIO) < 0) { + Con_Printf ("Couldn't initialize SDL AUDIO: %s\n", SDL_GetError ()); + return 0; + }; + /* Set up the desired format */ desired.freq = desired_speed; switch (desired_bits) { @@ -207,11 +219,15 @@ SNDDMA_Submit (void) void SNDDMA_BlockSound (void) { + ++snd_blocked; } void SNDDMA_UnblockSound (void) { + if (!snd_blocked) + return; + --snd_blocked; } plugin_t * @@ -235,8 +251,10 @@ PluginInfo (void) { plugin_info_funcs.input = NULL; plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs; -// plugin_info_general_funcs.p_Init = SNDDMA_Init; // FIXME - plugin_info_general_funcs.p_Shutdown = SNDDMA_Shutdown; + plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars; + plugin_info_general_funcs.p_Shutdown = NULL; + plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init; + plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown; plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos; plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit; plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound; diff --git a/libs/audio/targets/snd_sun.c b/libs/audio/targets/snd_sun.c index a988cb4ce..c602de72c 100644 --- a/libs/audio/targets/snd_sun.c +++ b/libs/audio/targets/snd_sun.c @@ -54,6 +54,7 @@ int audio_fd; int snd_inited; +int snd_blocked = 0; static int wbufp; static audio_info_t info; @@ -240,6 +241,20 @@ SNDDMA_Submit (void) } +void +SNDDMA_BlockSound (void) +{ + ++snd_blocked; +} + +void +SNDDMA_UnblockSound (void) +{ + if (!snd_blocked) + return; + --snd_blocked; +} + plugin_t * PluginInfo (void) { plugin_info.type = qfp_sound; @@ -282,13 +297,3 @@ PluginInfo (void) { return &plugin_info; } - -void -SNDDMA_BlockSound (void) -{ -} - -void -SNDDMA_UnblockSound (void) -{ -} diff --git a/libs/audio/targets/snd_win.c b/libs/audio/targets/snd_win.c index d01481060..e451941e7 100644 --- a/libs/audio/targets/snd_win.c +++ b/libs/audio/targets/snd_win.c @@ -59,6 +59,7 @@ static qboolean primary_format_set; static int sample16; static int snd_sent, snd_completed; +int snd_blocked = 0; volatile dma_t sn; /* @@ -95,14 +96,10 @@ qboolean SNDDMA_InitWav (void); void S_BlockSound (void) { - -// DirectSound takes care of blocking itself - if (snd_iswave) { - snd_blocked++; - - if (snd_blocked == 1) + // DirectSound takes care of blocking itself + if (snd_iswave) + if (++snd_blocked == 1) waveOutReset (hWaveOut); - } } @@ -112,11 +109,10 @@ S_BlockSound (void) void S_UnblockSound (void) { - -// DirectSound takes care of blocking itself - if (snd_iswave) { - snd_blocked--; - } + // DirectSound takes care of blocking itself + if (snd_iswave) + if (!snd_blocked) + --snd_blocked; }