Skip to content

Commit

Permalink
Start simplifying audio driver start/stop
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Apr 18, 2017
1 parent 4159dc4 commit 662755c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
25 changes: 16 additions & 9 deletions audio/audio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,17 +975,33 @@ bool audio_driver_toggle_mute(void)

bool audio_driver_start(bool is_shutdown)
{
settings_t *settings = config_get_ptr();
if (!current_audio || !current_audio->start
|| !audio_driver_context_audio_data)
return false;
if (audio_driver_alive())
return false;
if (!settings || settings->audio.mute_enable)
return false;
return current_audio->start(audio_driver_context_audio_data, is_shutdown);
}

bool audio_driver_alive(void)
{
if ( current_audio
&& current_audio->alive
&& audio_driver_context_audio_data)
return current_audio->alive(audio_driver_context_audio_data);
return false;
}

bool audio_driver_stop(void)
{
if (!current_audio || !current_audio->stop
|| !audio_driver_context_audio_data)
return false;
if (!audio_driver_alive())
return false;
return current_audio->stop(audio_driver_context_audio_data);
}

Expand All @@ -995,15 +1011,6 @@ void audio_driver_unset_callback(void)
audio_callback.set_state = NULL;
}

bool audio_driver_alive(void)
{
if ( current_audio
&& current_audio->alive
&& audio_driver_context_audio_data)
return current_audio->alive(audio_driver_context_audio_data);
return false;
}

void audio_driver_frame_is_reverse(void)
{
/* We just rewound. Flush rewind audio buffer. */
Expand Down
17 changes: 4 additions & 13 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2076,24 +2076,15 @@ bool command_event(enum event_command cmd, void *data)
command_event_save_auto_state();
break;
case CMD_EVENT_AUDIO_STOP:
if (!audio_driver_alive())
return false;

if (!audio_driver_stop())
return false;
break;
case CMD_EVENT_AUDIO_START:
if (!audio_driver_start(runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)))
{
settings_t *settings = config_get_ptr();
if (audio_driver_alive())
return false;

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));
audio_driver_unset_active();
}
RARCH_ERR("%s\n",
msg_hash_to_str(MSG_FAILED_TO_START_AUDIO_DRIVER));
audio_driver_unset_active();
}
break;
case CMD_EVENT_AUDIO_MUTE_TOGGLE:
Expand Down

0 comments on commit 662755c

Please sign in to comment.