From 0972c19f77e65a220698f0dfd48c77ce224bb9ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Nov 2015 14:23:29 +0100 Subject: [PATCH] Add more RARCH_AUDIO_CTL commands --- audio/audio_driver.c | 24 ++++++------------------ audio/audio_driver.h | 6 ++---- command_event.c | 4 ++-- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index abaceaf7a9..8df35b4f2c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -436,12 +436,10 @@ void init_audio(void) audio_data.buffer_free_samples_count = 0; + /* Threaded driver is initially stopped. */ if (driver->audio_active && !settings->audio.mute_enable && audio_data.audio_callback.callback) - { - /* Threaded driver is initially stopped. */ - driver->audio->start(driver->audio_data); - } + audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL); return; @@ -505,21 +503,7 @@ void audio_driver_readjust_input_rate(void) -bool audio_driver_start(void) -{ - driver_t *driver = driver_get_ptr(); - const audio_driver_t *audio = audio_get_ptr(driver); - return audio->start(driver->audio_data); -} - -bool audio_driver_stop(void) -{ - driver_t *driver = driver_get_ptr(); - const audio_driver_t *audio = audio_get_ptr(driver); - - return audio->stop(driver->audio_data); -} void audio_driver_set_nonblock_state(bool toggle) { @@ -862,6 +846,10 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) break; case RARCH_AUDIO_CTL_ALIVE: return audio->alive(driver->audio_data); + case RARCH_AUDIO_CTL_START: + return audio->start(driver->audio_data); + case RARCH_AUDIO_CTL_STOP: + return audio->stop(driver->audio_data); } return false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 01c94c1ab1..aee67a3693 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -75,6 +75,8 @@ typedef struct audio_driver enum rarch_audio_ctl_state { RARCH_AUDIO_CTL_NONE = 0, + RARCH_AUDIO_CTL_START, + RARCH_AUDIO_CTL_STOP, RARCH_AUDIO_CTL_ALIVE }; @@ -107,10 +109,6 @@ bool audio_driver_mute_toggle(void); */ void audio_driver_readjust_input_rate(void); -bool audio_driver_start(void); - -bool audio_driver_stop(void); - void audio_driver_set_nonblock_state(bool toggle); void audio_driver_set_nonblocking_state(bool enable); diff --git a/command_event.c b/command_event.c index fd69c97c53..82d949c9c9 100644 --- a/command_event.c +++ b/command_event.c @@ -1306,14 +1306,14 @@ bool event_command(enum event_command cmd) if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) return false; - if (!audio_driver_stop()) + if (!audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL)) return false; break; case EVENT_CMD_AUDIO_START: if (!driver->audio_data || audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) return false; - if (!settings->audio.mute_enable && !audio_driver_start()) + if (!settings->audio.mute_enable && !audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL)) { RARCH_ERR("Failed to start audio driver. Will continue without audio.\n"); driver->audio_active = false;