mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
(audio driver) refactor functions
This commit is contained in:
parent
7e1a06d8dd
commit
93d16aaba3
@ -448,7 +448,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
|||||||
&& !settings->audio.mute_enable
|
&& !settings->audio.mute_enable
|
||||||
&& audio_cb_inited
|
&& audio_cb_inited
|
||||||
)
|
)
|
||||||
audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL);
|
audio_driver_start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -937,6 +937,22 @@ bool audio_driver_toggle_mute(void)
|
|||||||
return true;
|
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)
|
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
@ -958,16 +974,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
|
|||||||
|| !audio_driver_context_audio_data)
|
|| !audio_driver_context_audio_data)
|
||||||
return false;
|
return false;
|
||||||
return current_audio->alive(audio_driver_context_audio_data);
|
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:
|
case RARCH_AUDIO_CTL_SET_OWN_DRIVER:
|
||||||
audio_driver_data_own = true;
|
audio_driver_data_own = true;
|
||||||
break;
|
break;
|
||||||
|
@ -42,8 +42,6 @@ enum rarch_audio_ctl_state
|
|||||||
RARCH_AUDIO_CTL_NONE = 0,
|
RARCH_AUDIO_CTL_NONE = 0,
|
||||||
RARCH_AUDIO_CTL_DESTROY,
|
RARCH_AUDIO_CTL_DESTROY,
|
||||||
RARCH_AUDIO_CTL_DESTROY_DATA,
|
RARCH_AUDIO_CTL_DESTROY_DATA,
|
||||||
RARCH_AUDIO_CTL_START,
|
|
||||||
RARCH_AUDIO_CTL_STOP,
|
|
||||||
RARCH_AUDIO_CTL_UNSET_CALLBACK,
|
RARCH_AUDIO_CTL_UNSET_CALLBACK,
|
||||||
RARCH_AUDIO_CTL_ALIVE,
|
RARCH_AUDIO_CTL_ALIVE,
|
||||||
RARCH_AUDIO_CTL_FRAME_IS_REVERSE,
|
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_toggle_mute(void);
|
||||||
|
|
||||||
|
bool audio_driver_start(void);
|
||||||
|
|
||||||
|
bool audio_driver_stop(void);
|
||||||
|
|
||||||
bool audio_driver_deinit(void);
|
bool audio_driver_deinit(void);
|
||||||
|
|
||||||
bool audio_driver_init(void);
|
bool audio_driver_init(void);
|
||||||
|
@ -1214,15 +1214,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data)
|
|||||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL))
|
if (!audio_driver_stop())
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case EVENT_CMD_AUDIO_START:
|
case EVENT_CMD_AUDIO_START:
|
||||||
if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!settings->audio.mute_enable &&
|
if (!settings->audio.mute_enable && !audio_driver_start())
|
||||||
!audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL))
|
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to start audio driver. "
|
RARCH_ERR("Failed to start audio driver. "
|
||||||
"Will continue without audio.\n");
|
"Will continue without audio.\n");
|
||||||
|
@ -336,7 +336,7 @@ bool core_unload(void)
|
|||||||
bool core_unload_game(void)
|
bool core_unload_game(void)
|
||||||
{
|
{
|
||||||
video_driver_deinit_hw_context();
|
video_driver_deinit_hw_context();
|
||||||
audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL);
|
audio_driver_stop();
|
||||||
core.retro_unload_game();
|
core.retro_unload_game();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user