(audio driver) refactor functions

This commit is contained in:
twinaphex 2016-05-08 18:00:32 +02:00
parent 7e1a06d8dd
commit 93d16aaba3
4 changed files with 24 additions and 17 deletions

View File

@ -448,7 +448,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
&& !settings->audio.mute_enable
&& audio_cb_inited
)
audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL);
audio_driver_start();
return true;
@ -937,6 +937,22 @@ bool audio_driver_toggle_mute(void)
return true;
}
bool audio_driver_start(void)
{
if (!current_audio || !current_audio->start
|| !audio_driver_context_audio_data)
return false;
return current_audio->start(audio_driver_context_audio_data);
}
bool audio_driver_stop(void)
{
if (!current_audio || !current_audio->stop
|| !audio_driver_context_audio_data)
return false;
return current_audio->stop(audio_driver_context_audio_data);
}
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
{
switch (state)
@ -958,16 +974,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
|| !audio_driver_context_audio_data)
return false;
return current_audio->alive(audio_driver_context_audio_data);
case RARCH_AUDIO_CTL_START:
if (!current_audio || !current_audio->start
|| !audio_driver_context_audio_data)
return false;
return current_audio->start(audio_driver_context_audio_data);
case RARCH_AUDIO_CTL_STOP:
if (!current_audio || !current_audio->stop
|| !audio_driver_context_audio_data)
return false;
return current_audio->stop(audio_driver_context_audio_data);
case RARCH_AUDIO_CTL_SET_OWN_DRIVER:
audio_driver_data_own = true;
break;

View File

@ -42,8 +42,6 @@ enum rarch_audio_ctl_state
RARCH_AUDIO_CTL_NONE = 0,
RARCH_AUDIO_CTL_DESTROY,
RARCH_AUDIO_CTL_DESTROY_DATA,
RARCH_AUDIO_CTL_START,
RARCH_AUDIO_CTL_STOP,
RARCH_AUDIO_CTL_UNSET_CALLBACK,
RARCH_AUDIO_CTL_ALIVE,
RARCH_AUDIO_CTL_FRAME_IS_REVERSE,
@ -187,6 +185,10 @@ bool audio_driver_find_driver(void);
bool audio_driver_toggle_mute(void);
bool audio_driver_start(void);
bool audio_driver_stop(void);
bool audio_driver_deinit(void);
bool audio_driver_init(void);

View File

@ -1214,15 +1214,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data)
if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
return false;
if (!audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL))
if (!audio_driver_stop())
return false;
break;
case EVENT_CMD_AUDIO_START:
if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
return false;
if (!settings->audio.mute_enable &&
!audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL))
if (!settings->audio.mute_enable && !audio_driver_start())
{
RARCH_ERR("Failed to start audio driver. "
"Will continue without audio.\n");

View File

@ -336,7 +336,7 @@ bool core_unload(void)
bool core_unload_game(void)
{
video_driver_deinit_hw_context();
audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL);
audio_driver_stop();
core.retro_unload_game();
return true;
}