(audio driver) Cleanups

This commit is contained in:
twinaphex 2016-05-08 18:03:09 +02:00
parent 93d16aaba3
commit de71776405
4 changed files with 21 additions and 14 deletions

View File

@ -953,6 +953,20 @@ bool audio_driver_stop(void)
return current_audio->stop(audio_driver_context_audio_data);
}
void audio_driver_unset_callback(void)
{
audio_callback.callback = NULL;
audio_callback.set_state = NULL;
}
bool audio_driver_alive(void)
{
if (!current_audio || !current_audio->alive
|| !audio_driver_context_audio_data)
return false;
return current_audio->alive(audio_driver_context_audio_data);
}
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
{
switch (state)
@ -965,15 +979,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
case RARCH_AUDIO_CTL_DESTROY_DATA:
audio_driver_context_audio_data = NULL;
break;
case RARCH_AUDIO_CTL_UNSET_CALLBACK:
audio_callback.callback = NULL;
audio_callback.set_state = NULL;
break;
case RARCH_AUDIO_CTL_ALIVE:
if (!current_audio || !current_audio->alive
|| !audio_driver_context_audio_data)
return false;
return current_audio->alive(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_UNSET_CALLBACK,
RARCH_AUDIO_CTL_ALIVE,
RARCH_AUDIO_CTL_FRAME_IS_REVERSE,
RARCH_AUDIO_CTL_SET_OWN_DRIVER,
RARCH_AUDIO_CTL_UNSET_OWN_DRIVER,
@ -189,6 +187,10 @@ bool audio_driver_start(void);
bool audio_driver_stop(void);
void audio_driver_unset_callback(void);
bool audio_driver_alive(void);
bool audio_driver_deinit(void);
bool audio_driver_init(void);

View File

@ -1211,14 +1211,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data)
event_save_auto_state();
break;
case EVENT_CMD_AUDIO_STOP:
if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
if (!audio_driver_alive())
return false;
if (!audio_driver_stop())
return false;
break;
case EVENT_CMD_AUDIO_START:
if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
if (!audio_driver_alive())
return false;
if (!settings->audio.mute_enable && !audio_driver_start())

View File

@ -707,7 +707,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
runloop_key_event = NULL;
runloop_frontend_key_event = NULL;
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_CALLBACK, NULL);
audio_driver_unset_callback();
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
break;
case RUNLOOP_CTL_SET_FRAME_TIME_LAST: