From dcf4037582fcc8d4ec14d83320f6019cb286ec2d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 23:01:03 +0200 Subject: [PATCH] (Audio drivers) Get rid of global state dependencies --- audio/drivers/ctr_audio.c | 2 ++ audio/drivers/ps3_audio.c | 3 ++- audio/drivers/xaudio.cpp | 14 +++++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/audio/drivers/ctr_audio.c b/audio/drivers/ctr_audio.c index e9b26d2d4b..b171664432 100644 --- a/audio/drivers/ctr_audio.c +++ b/audio/drivers/ctr_audio.c @@ -185,6 +185,8 @@ static bool ctr_audio_alive(void *data) static bool ctr_audio_start(void *data) { ctr_audio_t* ctr = (ctr_audio_t*)data; + /* TODO/FIXME - we should not depend upon global state + * in audio/video/input drivers. */ global_t *global = global_get_ptr(); /* prevents restarting audio when the menu diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index 335c7d74d7..f03dc08ad9 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -81,7 +81,6 @@ static void *ps3_audio_init(const char *device, { CellAudioPortParam params; ps3_audio_t *data = NULL; - global_t *global = global_get_ptr(); (void)latency; (void)device; @@ -95,10 +94,12 @@ static void *ps3_audio_init(const char *device, params.numChannels = AUDIO_CHANNELS; params.numBlocks = AUDIO_BLOCKS; +#if 0 #ifdef HAVE_HEADSET if(global->console.sound.mode == SOUND_MODE_HEADSET) params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY; else +#endif #endif params.param_attrib = 0; diff --git a/audio/drivers/xaudio.cpp b/audio/drivers/xaudio.cpp index 1863f142f6..3dd9173ffc 100644 --- a/audio/drivers/xaudio.cpp +++ b/audio/drivers/xaudio.cpp @@ -77,6 +77,7 @@ struct xaudio2 : public IXAudio2VoiceCallback unsigned write_buffer; }; +#if 0 static void xaudio2_enumerate_devices(xaudio2_t *xa) { uint32_t dev_count = 0; @@ -97,6 +98,7 @@ static void xaudio2_enumerate_devices(xaudio2_t *xa) } #endif } +#endif static void xaudio2_set_wavefmt(WAVEFORMATEX *wfx, unsigned channels, unsigned samplerate) @@ -226,17 +228,14 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_) static void *xa_init(const char *device, unsigned rate, unsigned latency) { size_t bufsize; - xa_t *xa = NULL; unsigned device_index = 0; - global_t *global = global_get_ptr(); + xa_t *xa = (xa_t*)calloc(1, sizeof(*xa)); + if (!xa) + return NULL; if (latency < 8) latency = 8; /* Do not allow shenanigans. */ - xa = (xa_t*)calloc(1, sizeof(*xa)); - if (!xa) - return NULL; - bufsize = latency * rate / 1000; RARCH_LOG("XAudio2: Requesting %u ms latency, using %d ms latency.\n", @@ -255,9 +254,6 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency) return NULL; } - if (global->verbosity) - xaudio2_enumerate_devices(xa->xa); - return xa; }