From 90bc170829a9f30cd88cd2f3bf990215209b16e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Jan 2017 18:05:07 +0100 Subject: [PATCH] Get rid of runloop_ctl calls inside audio drivers --- audio/audio_driver.c | 6 +++--- audio/audio_driver.h | 4 ++-- audio/audio_thread_wrapper.c | 8 +++++--- audio/drivers/alsa.c | 2 +- audio/drivers/alsa_qsa.c | 2 +- audio/drivers/alsathread.c | 2 +- audio/drivers/coreaudio.c | 2 +- audio/drivers/ctr_csnd_audio.c | 6 ++---- audio/drivers/ctr_dsp_audio.c | 6 ++---- audio/drivers/dsound.c | 2 +- audio/drivers/gx_audio.c | 2 +- audio/drivers/jack.c | 2 +- audio/drivers/nullaudio.c | 2 +- audio/drivers/openal.c | 2 +- audio/drivers/opensl.c | 2 +- audio/drivers/oss.c | 2 +- audio/drivers/ps3_audio.c | 2 +- audio/drivers/psp_audio.c | 2 +- audio/drivers/pulse.c | 2 +- audio/drivers/roar.c | 2 +- audio/drivers/rsound.c | 2 +- audio/drivers/rwebaudio.c | 2 +- audio/drivers/sdl_audio.c | 2 +- audio/drivers/wiiu_audio.c | 6 ++---- audio/drivers/xaudio.cpp | 2 +- audio/drivers/xenon360_audio.c | 2 +- command.c | 2 +- 27 files changed, 37 insertions(+), 41 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index f62d1cc5cb..084c1e573e 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -470,7 +470,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) && !settings->audio.mute_enable && audio_cb_inited ) - audio_driver_start(); + audio_driver_start(false); return true; @@ -968,12 +968,12 @@ bool audio_driver_toggle_mute(void) return true; } -bool audio_driver_start(void) +bool audio_driver_start(bool is_shutdown) { if (!current_audio || !current_audio->start || !audio_driver_context_audio_data) return false; - return current_audio->start(audio_driver_context_audio_data); + return current_audio->start(audio_driver_context_audio_data, is_shutdown); } bool audio_driver_stop(void) diff --git a/audio/audio_driver.h b/audio/audio_driver.h index bf2e27fe59..10ce09f044 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -55,7 +55,7 @@ typedef struct audio_driver bool (*stop)(void *data); /* Starts driver. */ - bool (*start)(void *data); + bool (*start)(void *data, bool is_shutdown); /* Is the audio driver currently running? */ bool (*alive)(void *data); @@ -171,7 +171,7 @@ bool audio_driver_find_driver(void); bool audio_driver_toggle_mute(void); -bool audio_driver_start(void); +bool audio_driver_start(bool is_shutdown); bool audio_driver_stop(void); diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 05ae867c37..7e383a112d 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -35,6 +35,7 @@ typedef struct audio_thread bool stopped; bool stopped_ack; bool is_paused; + bool is_shutdown; bool use_float; int inited; @@ -100,7 +101,7 @@ static void audio_thread_loop(void *data) scond_wait(thr->cond, thr->lock); } - thr->driver->start(thr->driver_data); + thr->driver->start(thr->driver_data, thr->is_shutdown); } slock_unlock(thr->lock); @@ -197,7 +198,7 @@ static bool audio_thread_stop(void *data) return true; } -static bool audio_thread_start(void *data) +static bool audio_thread_start(void *data, bool is_shutdown) { audio_thread_t *thr = (audio_thread_t*)data; @@ -206,7 +207,8 @@ static bool audio_thread_start(void *data) audio_driver_enable_callback(); - thr->is_paused = false; + thr->is_paused = false; + thr->is_shutdown = is_shutdown; audio_thread_unblock(thr); return true; diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index 2be0ff06f3..3bdf9b41bc 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -271,7 +271,7 @@ static void alsa_set_nonblock_state(void *data, bool state) alsa->nonblock = state; } -static bool alsa_start(void *data) +static bool alsa_start(void *data, bool is_shutdown) { alsa_t *alsa = (alsa_t*)data; diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index 71edeea6cb..ef0fbab51d 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -290,7 +290,7 @@ static bool alsa_qsa_alive(void *data) return false; } -static bool alsa_qsa_start(void *data) +static bool alsa_qsa_start(void *data, bool is_shutdown) { alsa_t *alsa = (alsa_t*)data; diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index 977705b1a0..c4e9d06f65 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -318,7 +318,7 @@ static void alsa_thread_set_nonblock_state(void *data, bool state) alsa->nonblock = state; } -static bool alsa_thread_start(void *data) +static bool alsa_thread_start(void *data, bool is_shutdown) { alsa_thread_t *alsa = (alsa_thread_t*)data; diff --git a/audio/drivers/coreaudio.c b/audio/drivers/coreaudio.c index a17ead090f..bac9e59d0a 100644 --- a/audio/drivers/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -397,7 +397,7 @@ static bool coreaudio_stop(void *data) return dev->is_paused ? true : false; } -static bool coreaudio_start(void *data) +static bool coreaudio_start(void *data, bool is_shutdown) { coreaudio_t *dev = (coreaudio_t*)data; if (!dev) diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 270e95aeeb..9310f3a255 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -20,7 +20,6 @@ #include "../audio_driver.h" #include "../../performance_counters.h" -#include "../../runloop.h" typedef struct { @@ -242,14 +241,13 @@ static bool ctr_csnd_audio_alive(void *data) return ctr->playing; } -static bool ctr_csnd_audio_start(void *data) +static bool ctr_csnd_audio_start(void *data, bool is_shutdown) { ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data; /* Prevents restarting audio when the menu * is toggled off on shutdown */ - - if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) + if (is_shutdown) return true; #if 0 diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index 91d7f4e940..e261879d87 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -19,7 +19,6 @@ #include "../audio_driver.h" #include "../../performance_counters.h" -#include "../../runloop.h" #include "../../ctr/ctr_debug.h" typedef struct @@ -162,14 +161,13 @@ static bool ctr_dsp_audio_alive(void *data) return ctr->playing; } -static bool ctr_dsp_audio_start(void *data) +static bool ctr_dsp_audio_start(void *data, bool is_shutdown) { ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data; /* Prevents restarting audio when the menu * is toggled off on shutdown */ - - if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) + if (is_shutdown) return true; ndspSetMasterVol(1.0); diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index 9264b3e705..1af78d9c15 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -396,7 +396,7 @@ static bool dsound_stop(void *data) return (ds->is_paused) ? true : false; } -static bool dsound_start(void *data) +static bool dsound_start(void *data, bool is_shutdown) { dsound_t *ds = (dsound_t*)data; diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 5d6c6680df..d495c4e6f2 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -173,7 +173,7 @@ static void gx_audio_set_nonblock_state(void *data, bool state) wa->nonblock = state; } -static bool gx_audio_start(void *data) +static bool gx_audio_start(void *data, bool is_shutdown) { gx_audio_t *wa = (gx_audio_t*)data; diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 08ce009148..ee0cb78d70 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -322,7 +322,7 @@ static void ja_set_nonblock_state(void *data, bool state) jd->nonblock = state; } -static bool ja_start(void *data) +static bool ja_start(void *data, bool is_shutdown) { jack_t *jd = (jack_t*)data; if (jd) diff --git a/audio/drivers/nullaudio.c b/audio/drivers/nullaudio.c index 694940f53a..d0d9c0d36b 100644 --- a/audio/drivers/nullaudio.c +++ b/audio/drivers/nullaudio.c @@ -55,7 +55,7 @@ static bool null_audio_alive(void *data) return true; } -static bool null_audio_start(void *data) +static bool null_audio_start(void *data, bool is_shutdown) { (void)data; return true; diff --git a/audio/drivers/openal.c b/audio/drivers/openal.c index 61200262ad..fc94f78e29 100644 --- a/audio/drivers/openal.c +++ b/audio/drivers/openal.c @@ -235,7 +235,7 @@ static void al_set_nonblock_state(void *data, bool state) al->nonblock = state; } -static bool al_start(void *data) +static bool al_start(void *data, bool is_shutdown) { al_t *al = (al_t*)data; if (al) diff --git a/audio/drivers/opensl.c b/audio/drivers/opensl.c index 0de157d433..7fe162ef57 100644 --- a/audio/drivers/opensl.c +++ b/audio/drivers/opensl.c @@ -221,7 +221,7 @@ static void sl_set_nonblock_state(void *data, bool state) sl->nonblock = state; } -static bool sl_start(void *data) +static bool sl_start(void *data, bool is_shutdown) { sl_t *sl = (sl_t*)data; sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_PLAYING) diff --git a/audio/drivers/oss.c b/audio/drivers/oss.c index 8a68573793..c7b84bc8bf 100644 --- a/audio/drivers/oss.c +++ b/audio/drivers/oss.c @@ -125,7 +125,7 @@ static bool oss_stop(void *data) return true; } -static bool oss_start(void *data) +static bool oss_start(void *data, bool is_shutdown) { (void)data; oss_is_paused = false; diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index 28bfb68825..38358babf5 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -177,7 +177,7 @@ static bool ps3_audio_stop(void *data) return true; } -static bool ps3_audio_start(void *data) +static bool ps3_audio_start(void *data, bool is_shutdown) { ps3_audio_t *aud = data; if (!aud->started) diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 0b7c3e305e..0181c9614a 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -285,7 +285,7 @@ static bool psp_audio_stop(void *data) return true; } -static bool psp_audio_start(void *data) +static bool psp_audio_start(void *data, bool is_shutdown) { SceKernelThreadInfo info; psp_audio_t* psp = (psp_audio_t*)data; diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index c1beefcd06..61e47fd08f 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -291,7 +291,7 @@ static bool pulse_alive(void *data) return !pa->is_paused; } -static bool pulse_start(void *data) +static bool pulse_start(void *data, bool is_shutdown) { bool ret; pa_t *pa = (pa_t*)data; diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 5b92bf1b69..374287ae10 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -109,7 +109,7 @@ static void ra_set_nonblock_state(void *data, bool state) roar->nonblocking = state; } -static bool ra_start(void *data) +static bool ra_start(void *data, bool is_shutdown) { roar_t *roar = (roar_t*)data; if (roar) diff --git a/audio/drivers/rsound.c b/audio/drivers/rsound.c index ff5bf749f1..258f42aa2a 100644 --- a/audio/drivers/rsound.c +++ b/audio/drivers/rsound.c @@ -177,7 +177,7 @@ static bool rs_alive(void *data) return false; } -static bool rs_start(void *data) +static bool rs_start(void *data, bool is_shutdown) { rsd_t *rsd = (rsd_t*)data; if (rsd_start(rsd->rd) < 0) diff --git a/audio/drivers/rwebaudio.c b/audio/drivers/rwebaudio.c index 1323389112..5a90e69233 100644 --- a/audio/drivers/rwebaudio.c +++ b/audio/drivers/rwebaudio.c @@ -76,7 +76,7 @@ static bool rwebaudio_alive(void *data) return !rwebaudio_is_paused; } -static bool rwebaudio_start(void *data) +static bool rwebaudio_start(void *data, bool is_shutdown) { (void)data; rwebaudio_is_paused = false; diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index a1bf693a12..0f36c15726 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -203,7 +203,7 @@ static bool sdl_audio_alive(void *data) return !sdl->is_paused; } -static bool sdl_audio_start(void *data) +static bool sdl_audio_start(void *data, bool is_shutdown) { sdl_audio_t *sdl = (sdl_audio_t*)data; sdl->is_paused = false; diff --git a/audio/drivers/wiiu_audio.c b/audio/drivers/wiiu_audio.c index 68f7620b37..a3b9116cf9 100644 --- a/audio/drivers/wiiu_audio.c +++ b/audio/drivers/wiiu_audio.c @@ -34,7 +34,6 @@ #include "audio/audio_driver.h" #include "performance_counters.h" -#include "runloop.h" typedef struct { @@ -180,14 +179,13 @@ static int ax_audio_limit(int in) return in; } -static bool ax_audio_start(void* data) +static bool ax_audio_start(void* data, bool is_shutdown) { ax_audio_t* ax = (ax_audio_t*)data; /* Prevents restarting audio when the menu * is toggled off on shutdown */ - - if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) + if (is_shutdown) return true; //set back to playing on enough buffered data diff --git a/audio/drivers/xaudio.cpp b/audio/drivers/xaudio.cpp index 74c29396af..42f6ce5944 100644 --- a/audio/drivers/xaudio.cpp +++ b/audio/drivers/xaudio.cpp @@ -316,7 +316,7 @@ static void xa_set_nonblock_state(void *data, bool state) xa->nonblock = state; } -static bool xa_start(void *data) +static bool xa_start(void *data, bool is_shutdown) { xa_t *xa = (xa_t*)data; xa->is_paused = false; diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index 4ab1236718..b72e01fc4d 100644 --- a/audio/drivers/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -112,7 +112,7 @@ static void xenon360_audio_set_nonblock_state(void *data, bool state) xa->nonblock = state; } -static bool xenon360_audio_start(void *data) +static bool xenon360_audio_start(void *data, bool is_shutdown) { xenon_audio_t *xa = data; xa->is_paused = false; diff --git a/command.c b/command.c index 8326787a9e..e3c39434d7 100644 --- a/command.c +++ b/command.c @@ -2055,7 +2055,7 @@ bool command_event(enum event_command cmd, void *data) if (audio_driver_alive()) return false; - if (settings && !settings->audio.mute_enable && !audio_driver_start()) + if (settings && !settings->audio.mute_enable && !audio_driver_start(runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_AUDIO_DRIVER));