Build fixes, notably for snd_sdl.c. It segfaults on shutdown though

:/
This commit is contained in:
Adam Olsen 2001-08-23 11:40:53 +00:00
parent e935351cd1
commit 90849100fe
6 changed files with 56 additions and 35 deletions

View file

@ -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;

View file

@ -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 *

View file

@ -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--;
}

View file

@ -36,6 +36,7 @@
# include <strings.h>
#endif
#include <SDL.h>
#include <SDL_audio.h>
#include <SDL_byteorder.h>
#include <stdlib.h>
@ -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;

View file

@ -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)
{
}

View file

@ -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;
}