Refactor : renamed methods and eliminated unused parameters

This commit is contained in:
Aaron Culliney
2015-06-16 23:32:19 -07:00
parent 060c95e873
commit 433f079610
5 changed files with 21 additions and 15 deletions

View File

@@ -1369,7 +1369,7 @@ static bool MB_DSInit()
if(!audio_isAvailable) if(!audio_isAvailable)
return false; return false;
int hr = DSGetSoundBuffer(&MockingboardVoice, DSBCAPS_CTRLVOLUME, g_dwDSBufferSize, SAMPLE_RATE, 2); int hr = audio_createSoundBuffer(&MockingboardVoice, g_dwDSBufferSize, SAMPLE_RATE, 2);
LOG("MB_DSInit: DSGetSoundBuffer(), hr=0x%08X\n", (unsigned int)hr); LOG("MB_DSInit: DSGetSoundBuffer(), hr=0x%08X\n", (unsigned int)hr);
if(FAILED(hr)) if(FAILED(hr))
{ {
@@ -1466,7 +1466,7 @@ static bool MB_DSInit()
unsigned int nPhonemeByteLength = g_nPhonemeInfo[nPhoneme].nLength * sizeof(int16_t); unsigned int nPhonemeByteLength = g_nPhonemeInfo[nPhoneme].nLength * sizeof(int16_t);
// NB. DSBCAPS_LOCSOFTWARE required for // NB. DSBCAPS_LOCSOFTWARE required for
hr = DSGetSoundBuffer(&SSI263Voice[i], DSBCAPS_CTRLVOLUME+DSBCAPS_CTRLPOSITIONNOTIFY+DSBCAPS_LOCSOFTWARE, nPhonemeByteLength, 22050, 1); hr = audio_createSoundBuffer(&SSI263Voice[i], nPhonemeByteLength, 22050, 1);
LOG("MB_DSInit: (%02d) DSGetSoundBuffer(), hr=0x%08X\n", i, (unsigned int)hr); LOG("MB_DSInit: (%02d) DSGetSoundBuffer(), hr=0x%08X\n", i, (unsigned int)hr);
if(FAILED(hr)) if(FAILED(hr))
{ {
@@ -1614,7 +1614,7 @@ static void MB_DSUninit()
MockingboardVoice->bActive = false; MockingboardVoice->bActive = false;
} }
DSReleaseSoundBuffer(&MockingboardVoice); audio_destroySoundBuffer(&MockingboardVoice);
// //
@@ -1630,7 +1630,7 @@ static void MB_DSUninit()
SSI263Voice[i]->bActive = false; SSI263Voice[i]->bActive = false;
} }
DSReleaseSoundBuffer(&SSI263Voice[i]); audio_destroySoundBuffer(&SSI263Voice[i]);
} }
// //

View File

@@ -151,7 +151,7 @@ static void PlaylistDequeue(ALVoice *voice, ALPlayBuf *node)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static long openal_systemInit(const char *sound_device, AudioContext_s **audio_context) static long openal_systemSetup(const char *sound_device, AudioContext_s **audio_context)
{ {
assert(*audio_context == NULL); assert(*audio_context == NULL);
assert(voices == NULL); assert(voices == NULL);
@@ -821,7 +821,7 @@ __attribute__((constructor(CTOR_PRIORITY_EARLY)))
static void _init_openal(void) { static void _init_openal(void) {
LOG("Initializing OpenAL sound system"); LOG("Initializing OpenAL sound system");
openal_audio_backend.init = &openal_systemInit; openal_audio_backend.setup = &openal_systemSetup;
openal_audio_backend.shutdown = &openal_systemShutdown; openal_audio_backend.shutdown = &openal_systemShutdown;
openal_audio_backend.pause = &openal_systemPause; openal_audio_backend.pause = &openal_systemPause;
openal_audio_backend.resume = &openal_systemResume; openal_audio_backend.resume = &openal_systemResume;

View File

@@ -24,7 +24,7 @@ AudioBackend_s *audio_backend = NULL;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
long DSGetSoundBuffer(INOUT AudioBuffer_s **pVoice, unsigned long dwFlags, unsigned long dwBufferSize, unsigned long nSampleRate, int nChannels) { long audio_createSoundBuffer(INOUT AudioBuffer_s **pVoice, unsigned long dwBufferSize, unsigned long nSampleRate, int nChannels) {
AudioParams_s params = { 0 }; AudioParams_s params = { 0 };
params.nChannels = nChannels; params.nChannels = nChannels;
@@ -35,7 +35,7 @@ long DSGetSoundBuffer(INOUT AudioBuffer_s **pVoice, unsigned long dwFlags, unsig
params.dwBufferBytes = dwBufferSize; params.dwBufferBytes = dwBufferSize;
if (*pVoice) { if (*pVoice) {
DSReleaseSoundBuffer(pVoice); audio_destroySoundBuffer(pVoice);
} }
long err = 0; long err = 0;
@@ -49,8 +49,8 @@ long DSGetSoundBuffer(INOUT AudioBuffer_s **pVoice, unsigned long dwFlags, unsig
return err; return err;
} }
void DSReleaseSoundBuffer(INOUT AudioBuffer_s **pVoice) { void audio_destroySoundBuffer(INOUT AudioBuffer_s **audioBuffer) {
audioContext->DestroySoundBuffer(pVoice); audioContext->DestroySoundBuffer(audioBuffer);
} }
bool audio_init(void) { bool audio_init(void) {

View File

@@ -59,9 +59,15 @@ typedef struct AudioBuffer_s {
} AudioBuffer_s; } AudioBuffer_s;
/*
* Creates a sound buffer object.
*/
long audio_createSoundBuffer(INOUT AudioBuffer_s **audioBuffer, unsigned long bufferSize, unsigned long sampleRate, int numChannels);
long DSGetSoundBuffer(INOUT AudioBuffer_s **pVoice, unsigned long dwFlags, unsigned long dwBufferSize, unsigned long nSampleRate, int nChannels); /*
void DSReleaseSoundBuffer(INOUT AudioBuffer_s **pVoice); * Destroy and nullify sound buffer object.
*/
void audio_destroySoundBuffer(INOUT AudioBuffer_s **pVoice);
/* /*
* Prepare the audio subsystem, including the backend renderer. * Prepare the audio subsystem, including the backend renderer.
@@ -109,7 +115,7 @@ typedef struct AudioContext_s {
typedef struct AudioBackend_s { typedef struct AudioBackend_s {
// basic backend functionality controlled by soundcore // basic backend functionality controlled by soundcore
PRIVATE long (*init)(const char *sound_device, INOUT AudioContext_s **audio_context); PRIVATE long (*setup)(const char *sound_device, INOUT AudioContext_s **audio_context);
PRIVATE long (*shutdown)(INOUT AudioContext_s **audio_context); PRIVATE long (*shutdown)(INOUT AudioContext_s **audio_context);
PRIVATE long (*enumerateDevices)(INOUT char ***sound_devices, const int maxcount); PRIVATE long (*enumerateDevices)(INOUT char ***sound_devices, const int maxcount);

View File

@@ -306,11 +306,11 @@ void speaker_destroy(void) {
if (speakerBuffer) { if (speakerBuffer) {
speakerBuffer->Stop(speakerBuffer->_this); speakerBuffer->Stop(speakerBuffer->_this);
} }
DSReleaseSoundBuffer(&speakerBuffer); audio_destroySoundBuffer(&speakerBuffer);
} }
void speaker_init(void) { void speaker_init(void) {
long err = DSGetSoundBuffer(&speakerBuffer, 0, SOUNDCORE_BUFFER_SIZE, SPKR_SAMPLE_RATE, 1); long err = audio_createSoundBuffer(&speakerBuffer, SOUNDCORE_BUFFER_SIZE, SPKR_SAMPLE_RATE, 1);
assert(!err); assert(!err);
_speaker_init_timing(); _speaker_init_timing();
} }