From fb7b97d868bf01f0a0a805138c633f67c168c4da Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 21 Apr 2013 11:27:31 +0200 Subject: [PATCH] Minor cleanups to snd_vorbis.c - Remove any forward declarations - Tightens checks for SDL --- src/client/sound/header/local.h | 6 ++++++ src/client/sound/snd_vorbis.c | 27 +++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/client/sound/header/local.h b/src/client/sound/header/local.h index 96479118..196c475c 100644 --- a/src/client/sound/header/local.h +++ b/src/client/sound/header/local.h @@ -329,6 +329,12 @@ void AL_Update(void); void AL_RawSamples(int samples, int rate, int width, int channels, byte *data, float volume); +/* + * Unqueues any raw samples + * still in flight + */ +void AL_UnqueueRawSamples(); + #endif /* USE_OPENAL */ #endif /* CL_SOUND_LOCAL_H */ diff --git a/src/client/sound/snd_vorbis.c b/src/client/sound/snd_vorbis.c index 0cb2b39d..3243f7da 100644 --- a/src/client/sound/snd_vorbis.c +++ b/src/client/sound/snd_vorbis.c @@ -20,9 +20,9 @@ * This file implements an interface to libvorbis for decoding * OGG/Vorbis files. Strongly spoken this file isn't part of the sound * system but part of the main client. It justs converts Vorbis streams - * into normal, raw Wave stream which are injected into snd_mem.c as if - * they were normal wave files. At this moment only background music - * playback and in theory .cin movie file playback is supported. + * into normal, raw Wave stream which are injected into the backends as + * if they were normal "raw" samples. At this moment only background + * music playback and in theory .cin movie file playback is supported. * * ======================================================================= */ @@ -39,10 +39,6 @@ #include "header/local.h" #include "header/vorbis.h" -#ifdef USE_OPENAL -void AL_UnqueueRawSamples(); -#endif - qboolean ogg_first_init = true; /* First initialization flag. */ qboolean ogg_started = false; /* Initialization flag. */ int ogg_bigendian = 0; @@ -60,7 +56,7 @@ cvar_t *ogg_sequence; /* Sequence play indicator. */ cvar_t *ogg_volume; /* Music volume. */ OggVorbis_File ovFile; /* Ogg Vorbis file. */ vorbis_info *ogg_info; /* Ogg Vorbis file information */ -int ogg_numbufs; /* Number of buffers for OpenAL */ +int ogg_numbufs; /* Number of buffers for OpenAL */ /* * Initialize the Ogg Vorbis subsystem. @@ -665,13 +661,16 @@ OGG_Stream(void) else /* using SDL */ #endif { - /* Read that number samples into the buffer, that - were played since the last call to this function. - This keeps the buffer at all times at an "optimal" - fill level. */ - while (paintedtime + MAX_RAW_SAMPLES - 2048 > s_rawend) + if (sound_started == SS_SDL) { - OGG_Read(); + /* Read that number samples into the buffer, that + were played since the last call to this function. + This keeps the buffer at all times at an "optimal" + fill level. */ + while (paintedtime + MAX_RAW_SAMPLES - 2048 > s_rawend) + { + OGG_Read(); + } } } /* using SDL */ } /* ogg_status == PLAY */