From 25c15834c328ab8c9fea53ddcefb3f795eac2d8d Mon Sep 17 00:00:00 2001 From: sonninnos <45124675+sonninnos@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:12:24 +0200 Subject: [PATCH] Clean up and reduce refresh rate logging (#16259) --- gfx/video_driver.c | 19 ++++++++++++++----- retroarch.c | 8 +------- runloop.c | 6 ------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 81a6082b15..8b07efcc31 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1174,7 +1174,7 @@ bool video_display_server_set_resolution(unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust) { video_driver_state_t *video_st = &video_driver_st; - RARCH_DBG("[Video]: Display server set resolution, hz: %f\n",hz); + RARCH_DBG("[Video]: Display server set resolution to %ux%u %.3f Hz.\n", width, height, hz); if (current_display_server && current_display_server->set_resolution) return current_display_server->set_resolution( video_st->current_display_server_data, width, height, int_hz, @@ -1291,7 +1291,7 @@ void video_switch_refresh_rate_maybe( bool video_display_server_set_refresh_rate(float hz) { video_driver_state_t *video_st = &video_driver_st; - RARCH_DBG("[Video]: Display server set refresh rate %f\n", hz); + RARCH_DBG("[Video]: Display server set refresh rate to %.3f Hz.\n", hz); if (current_display_server && current_display_server->set_resolution) return current_display_server->set_resolution( video_st->current_display_server_data, 0, 0, (int)hz, @@ -1308,9 +1308,18 @@ void video_display_server_restore_refresh_rate(void) if (!refresh_rate_original || refresh_rate_current == refresh_rate_original) return; - RARCH_DBG("[Video]: Display server restore refresh rate %f\n", refresh_rate_original); - video_monitor_set_refresh_rate(refresh_rate_original); - video_display_server_set_refresh_rate(refresh_rate_original); + + RARCH_DBG("[Video]: Restoring original refresh rate: %.3f Hz.\n", video_st->video_refresh_rate_original); + + if (video_display_server_set_refresh_rate(refresh_rate_original)) + { + /* Set the av_info fps also to the original refresh rate */ + /* to avoid re-initialization problems */ + struct retro_system_av_info *av_info = &video_st->av_info; + av_info->timing.fps = video_st->video_refresh_rate_original; + + video_monitor_set_refresh_rate(refresh_rate_original); + } } const char *video_display_server_get_output_options(void) diff --git a/retroarch.c b/retroarch.c index e9742d6969..fd719ec483 100644 --- a/retroarch.c +++ b/retroarch.c @@ -8156,14 +8156,8 @@ bool retroarch_main_quit(void) /* Restore original refresh rate, if it has been changed * automatically in SET_SYSTEM_AV_INFO */ if (video_st->video_refresh_rate_original) - { - RARCH_DBG("[Video]: Restoring original refresh rate: %f Hz\n", video_st->video_refresh_rate_original); - /* Set the av_info fps also to the original refresh rate */ - /* to avoid re-initialization problems */ - av_info->timing.fps = video_st->video_refresh_rate_original; - video_display_server_restore_refresh_rate(); - } + if (!(runloop_st->flags & RUNLOOP_FLAG_SHUTDOWN_INITIATED)) { if (settings->bools.savestate_auto_save && diff --git a/runloop.c b/runloop.c index 43548b8d33..81ce5415fe 100644 --- a/runloop.c +++ b/runloop.c @@ -4097,13 +4097,7 @@ void runloop_event_deinit_core(void) /* Restore original refresh rate, if it has been changed * automatically in SET_SYSTEM_AV_INFO */ if (video_st->video_refresh_rate_original) - { - /* Set the av_info fps also to the original refresh rate */ - /* to avoid re-initialization problems */ - struct retro_system_av_info *av_info = &video_st->av_info; - av_info->timing.fps = video_st->video_refresh_rate_original; video_display_server_restore_refresh_rate(); - } /* Recalibrate frame delay target */ if (settings->bools.video_frame_delay_auto)