Skip to content

Commit b47ee1e

Browse files
committed
gfx: toggle Sync to Exact Content Framerate without a driver reinit
vrr_runloop_enable ("Sync to Exact Content Framerate") fired CMD_EVENT_REINIT on change, reinitialising video/audio/input and flashing the screen. But the VRR frame-timing is read per-frame in the runloop (swap-interval logic), so that part needs no reinit -- the hotkey toggle already flips the setting with none. The only init-time effect is the audio/video system-rate recompute in driver_adjust_system_rates(): VRR locks audio to the exact content rate rather than adjusting it to the display refresh. That recompute has a lightweight, existing entry point -- RARCH_DRIVER_CTL_SET_REFRESH_RATE, already used by the refresh-rate settings -- which calls driver_adjust_system_rates() without recreating any driver. So: - general_write_handler(): for VRR_RUNLOOP_ENABLE, re-adjust the rates via that ctl, and point the setting at CMD_EVENT_NONE instead of the reinit. - CMD_EVENT_VRR_RUNLOOP_TOGGLE (the hotkey): do the same rate re-adjust after flipping the value. Previously the hotkey changed frame timing but never recomputed the audio rate, leaving it stale until the next reinit; this makes the hotkey and the menu toggle consistent. Compile-verified. Reuses the existing SET_REFRESH_RATE rate-adjust path rather than a new lifecycle, but it does touch runtime audio timing, so it warrants an on-device check that toggling VRR still switches audio between exact-rate and adjusted correctly. Signed-off-by: LibretroAdmin <LibretroAdmin@users.noreply.github.com>
1 parent 29da841 commit b47ee1e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

menu/menu_setting.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8937,6 +8937,14 @@ static void general_write_handler(rarch_setting_t *setting)
89378937
#ifdef HAVE_CHEEVOS
89388938
rcheevos_validate_config_settings();
89398939
#endif
8940+
/* Sync to Exact Content Framerate only changes the audio/video
8941+
* system rates (audio locks to the exact content rate instead of the
8942+
* display refresh) plus the per-frame swap interval, so re-adjust the
8943+
* rates in place rather than reinitialising the drivers -- the runloop
8944+
* reads vrr_runloop_enable every frame. */
8945+
if (setting->enum_idx == MENU_ENUM_LABEL_VRR_RUNLOOP_ENABLE)
8946+
driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE,
8947+
&settings->floats.video_refresh_rate);
89408948
break;
89418949

89428950
case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO:
@@ -17325,7 +17333,7 @@ static bool setting_append_list(
1732517333
SDESC_BOOL_ROW(fastforward_frameskip, FASTFORWARD_FRAMESKIP,
1732617334
DEFAULT_FASTFORWARD_FRAMESKIP, SD_FLAG_NONE, 0, 0),
1732717335
SDESC_BOOL_ROW_EX(vrr_runloop_enable, VRR_RUNLOOP_ENABLE,
17328-
false, SD_FLAG_CMD_APPLY_AUTO, 0, CMD_EVENT_REINIT,
17336+
false, SD_FLAG_CMD_APPLY_AUTO, 0, CMD_EVENT_NONE,
1732917337
setting_bool_action_left_with_refresh, NULL, NULL, NULL, setting_bool_action_left_with_refresh, setting_bool_action_right_with_refresh, 0),
1733017338
};
1733117339
settings_list_add_desc(list, list_info, settings,

retroarch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5890,6 +5890,11 @@ bool command_event(enum event_command cmd, void *data)
58905890
settings->bools.vrr_runloop_enable ? MSG_VRR_RUNLOOP_ENABLED
58915891
: MSG_VRR_RUNLOOP_DISABLED);
58925892
settings->bools.vrr_runloop_enable = !(settings->bools.vrr_runloop_enable);
5893+
/* Re-adjust audio/video system rates for the new VRR mode so the
5894+
* hotkey matches the menu toggle instead of leaving the audio
5895+
* input rate stale until the next reinit. */
5896+
driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE,
5897+
&settings->floats.video_refresh_rate);
58935898
runloop_msg_queue_push(_msg, strlen(_msg), 1, 100, false, NULL,
58945899
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
58955900
}

0 commit comments

Comments
 (0)