From 2ae8468b10dbdced45ad747b91fc6ac965cea6bb Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sun, 12 Jul 2015 14:29:47 -0700 Subject: [PATCH] Fix desktop Linux build break --- src/audio/soundcore-openal.c | 19 ++++++++++++------- src/audio/soundcore.h | 8 ++++++++ src/audio/speaker.c | 14 -------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/audio/soundcore-openal.c b/src/audio/soundcore-openal.c index cf376842..c14430e6 100644 --- a/src/audio/soundcore-openal.c +++ b/src/audio/soundcore-openal.c @@ -264,7 +264,10 @@ static long ALUnlockBuffer(AudioBuffer_s *_this, unsigned long audio_bytes) { voice->index += audio_bytes; - assert((voice->index < voice->buffersize) && "OOPS, overflow in queued sound data"); + + if (voice->index >= voice->buffersize) { + assert((voice->index == voice->buffersize) && "OOPS, detected an actual overflow in queued sound data"); + } if (bytes_queued >= (voice->buffersize>>2)/*quarter buffersize*/) { // keep accumulating data into working buffer @@ -284,6 +287,7 @@ static long ALUnlockBuffer(AudioBuffer_s *_this, unsigned long audio_bytes) { return err; } +#if 0 // HACK Part I : done once for mockingboard that has semiauto repeating phonemes ... static long ALUnlockStaticBuffer(AudioBuffer_s *_this, unsigned long audio_bytes) { ALVoice *voice = (ALVoice*)_this->_internal; @@ -298,6 +302,7 @@ static long ALReplay(AudioBuffer_s *_this) { long err = _ALSubmitBufferToOpenAL(voice); return err; } +#endif static long ALGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) { *status = -1; @@ -466,7 +471,7 @@ static long openal_destroySoundBuffer(const struct AudioContext_s *sound_system, return 0; } -static long openal_createSoundBuffer(const AudioContext_s *audio_context, unsigned long numChannels, INOUT AudioBuffer_s **soundbuf_struct) { +static long openal_createSoundBuffer(const AudioContext_s *audio_context, INOUT AudioBuffer_s **soundbuf_struct) { LOG("openal_createSoundBuffer ..."); assert(*soundbuf_struct == NULL); @@ -477,7 +482,7 @@ static long openal_createSoundBuffer(const AudioContext_s *audio_context, unsign ALCcontext *ctx = (ALCcontext*)(audio_context->_internal); assert(ctx != NULL); - if ((voice = _openal_createVoice(numChannels)) == NULL) { + if ((voice = _openal_createVoice(NUM_CHANNELS)) == NULL) { ERRLOG("OOPS, Cannot create new voice"); break; } @@ -503,8 +508,8 @@ static long openal_createSoundBuffer(const AudioContext_s *audio_context, unsign (*soundbuf_struct)->Unlock = &ALUnlockBuffer; (*soundbuf_struct)->GetStatus = &ALGetStatus; // mockingboard-specific hacks - (*soundbuf_struct)->UnlockStaticBuffer = &ALUnlockStaticBuffer; - (*soundbuf_struct)->Replay = &ALReplay; + //(*soundbuf_struct)->UnlockStaticBuffer = &ALUnlockStaticBuffer; + //(*soundbuf_struct)->Replay = &ALReplay; return 0; } while(0); @@ -586,7 +591,7 @@ static long openal_systemSetup(INOUT AudioContext_s **audio_context) { return result; } -static long openal_systemPause(void) { +static long openal_systemPause(AudioContext_s *audio_context) { ALVoices *vnode = NULL; ALVoices *tmp = NULL; long err = 0; @@ -602,7 +607,7 @@ static long openal_systemPause(void) { return 0; } -static long openal_systemResume(void) { +static long openal_systemResume(AudioContext_s *audio_context) { ALVoices *vnode = NULL; ALVoices *tmp = NULL; long err = 0; diff --git a/src/audio/soundcore.h b/src/audio/soundcore.h index 12961dd6..d4e4d499 100644 --- a/src/audio/soundcore.h +++ b/src/audio/soundcore.h @@ -24,6 +24,14 @@ #define SOUNDCORE_ERROR_INC 20 #define SOUNDCORE_ERROR_MAX 200 +// Note to future self: +// +// Although output for the speaker could be MONO (and was at one point in time) ... we optimize the OpenSLES backend on +// Android to have just one buffer queue callback, where we need to mix both mockingboard and speaker samples. +// +// For now, just make everything use stereo for simplicity (including OpenAL backend). +#define NUM_CHANNELS 2 + typedef struct AudioBuffer_s { bool bActive; // Mockingboard ... refactor? bool bMute; // Mockingboard ... refactor? diff --git a/src/audio/speaker.c b/src/audio/speaker.c index a00c2ff9..61f6fd2a 100644 --- a/src/audio/speaker.c +++ b/src/audio/speaker.c @@ -31,20 +31,6 @@ #define SPKR_SILENT_STEP 1 -#if defined(ANDROID) -// Note to future self: -// -// This is a leaky backend implementation detail : we are optimizing to use only one OpenSLES buffer queue callback that -// mixes samples from both mockingboard and speaker (thus the speaker needs to be stereo to match mockingboard). -// -// This is different than the OpenAL backend implementation for desktop (Linux/Mac/...) which is a push-based local -// queue. -# define NUM_CHANNELS 2 -#else -// this can still be mono for other systems ... -# define NUM_CHANNELS 1 -#endif - static unsigned long bufferTotalSize = 0; static unsigned long bufferSizeIdealMin = 0; static unsigned long bufferSizeIdealMax = 0;