Skip to content

Commit

Permalink
Don't stop audio on menu toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Jul 27, 2023
1 parent e258235 commit e42796a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
17 changes: 2 additions & 15 deletions menu/menu_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -6107,7 +6107,6 @@ void menu_driver_toggle(
*/
video_driver_t *current_video = (video_driver_t*)curr_video_data;
bool pause_libretro = false;
bool audio_enable_menu = false;
runloop_state_t *runloop_st = runloop_state_get_ptr();
struct menu_state *menu_st = &menu_driver_state;
bool runloop_shutdown_initiated = runloop_st->flags &
Expand All @@ -6126,9 +6125,6 @@ void menu_driver_toggle(
#else
pause_libretro = settings->bools.menu_pause_libretro;
#endif
#ifdef HAVE_AUDIOMIXER
audio_enable_menu = settings->bools.audio_enable_menu;
#endif
#ifdef HAVE_OVERLAY
input_overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu;
input_overlay_enable = settings->bools.input_overlay_enable;
Expand Down Expand Up @@ -6197,13 +6193,10 @@ void menu_driver_toggle(
command_event(CMD_EVENT_RUMBLE_STOP, NULL);

if (pause_libretro)
{ /* If the menu pauses the game... */
{
#ifdef HAVE_MICROPHONE
command_event(CMD_EVENT_MICROPHONE_STOP, NULL);
#endif

if (!audio_enable_menu) /* If the menu shouldn't have audio... */
command_event(CMD_EVENT_AUDIO_STOP, NULL);
}

/* Override keyboard callback to redirect to menu instead.
Expand All @@ -6230,15 +6223,9 @@ void menu_driver_toggle(
driver_set_nonblock_state();

if (pause_libretro)
{ /* If the menu pauses the game... */

if (!audio_enable_menu) /* ...and the menu doesn't have audio... */
command_event(CMD_EVENT_AUDIO_START, NULL);
/* ...then re-enable the audio driver (which we shut off earlier) */

{
#ifdef HAVE_MICROPHONE
command_event(CMD_EVENT_MICROPHONE_START, NULL);
/* Start the microphone, if it was paused beforehand */
#endif
}

Expand Down
17 changes: 1 addition & 16 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,6 @@ bool command_event(enum event_command cmd, void *data)
#endif
break;
case CMD_EVENT_AUDIO_STOP:
midi_driver_set_all_sounds_off();
#if defined(HAVE_AUDIOMIXER) && defined(HAVE_MENU)
if ( settings->bools.audio_enable_menu
&& menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
Expand Down Expand Up @@ -3702,7 +3701,6 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_MENU_PAUSE_LIBRETRO:
#ifdef HAVE_MENU
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
{
#ifdef HAVE_NETWORKING
bool menu_pause_libretro = settings->bools.menu_pause_libretro
Expand All @@ -3711,31 +3709,18 @@ bool command_event(enum event_command cmd, void *data)
bool menu_pause_libretro = settings->bools.menu_pause_libretro;
#endif
if (menu_pause_libretro)
{ /* If entering the menu pauses the game... */
command_event(CMD_EVENT_AUDIO_STOP, NULL);
{
#ifdef HAVE_MICROPHONE
command_event(CMD_EVENT_MICROPHONE_STOP, NULL);
#endif
}
else
{
command_event(CMD_EVENT_AUDIO_START, NULL);
#ifdef HAVE_MICROPHONE
command_event(CMD_EVENT_MICROPHONE_START, NULL);
#endif
}
}
else
{
#ifdef HAVE_NETWORKING
bool menu_pause_libretro = settings->bools.menu_pause_libretro
&& netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL);
#else
bool menu_pause_libretro = settings->bools.menu_pause_libretro;
#endif
if (menu_pause_libretro)
command_event(CMD_EVENT_AUDIO_START, NULL);
}
#endif
break;
#ifdef HAVE_NETWORKING
Expand Down
7 changes: 6 additions & 1 deletion runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -4703,11 +4703,11 @@ void runloop_pause_checks(void)
#ifdef HAVE_PRESENCE
presence_userdata_t userdata;
#endif
video_driver_state_t *video_st = video_state_get_ptr();
runloop_state_t *runloop_st = &runloop_state;
bool is_paused = runloop_st->flags & RUNLOOP_FLAG_PAUSED;
bool is_idle = runloop_st->flags & RUNLOOP_FLAG_IDLE;
#if defined(HAVE_GFX_WIDGETS)
video_driver_state_t *video_st = video_state_get_ptr();
dispgfx_widget_t *p_dispwidget = dispwidget_get_ptr();
bool widgets_active = p_dispwidget->active;
if (widgets_active)
Expand All @@ -4731,6 +4731,8 @@ void runloop_pause_checks(void)
if (!is_idle)
video_driver_cached_frame();

midi_driver_set_all_sounds_off();

#ifdef HAVE_PRESENCE
userdata.status = PRESENCE_GAME_PAUSED;
command_event(CMD_EVENT_PRESENCE_UPDATE, &userdata);
Expand Down Expand Up @@ -4758,6 +4760,9 @@ void runloop_pause_checks(void)

/* Signal/reset paused rewind to take the initial step */
runloop_st->run_frames_and_pause = -1;

/* Ignore frame delay target temporarily */
video_st->frame_delay_pause = true;
}

struct string_list *path_get_subsystem_list(void)
Expand Down

0 comments on commit e42796a

Please sign in to comment.