mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
Refresh rate switching fixes and cleanups (#17021)
This commit is contained in:
parent
4ce7dd6fd5
commit
4b177d0ac7
@ -124,7 +124,9 @@ static void win32_display_server_destroy(void *data)
|
|||||||
if (!dispserv)
|
if (!dispserv)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dispserv->orig_width > 0 && dispserv->orig_height > 0)
|
if ( dispserv->orig_width > 0
|
||||||
|
&& dispserv->orig_height > 0
|
||||||
|
&& dispserv->orig_refresh > 0)
|
||||||
video_display_server_set_resolution(
|
video_display_server_set_resolution(
|
||||||
dispserv->orig_width,
|
dispserv->orig_width,
|
||||||
dispserv->orig_height,
|
dispserv->orig_height,
|
||||||
|
@ -1081,7 +1081,13 @@ const char *video_display_server_get_ident(void)
|
|||||||
void* video_display_server_init(enum rarch_display_type type)
|
void* video_display_server_init(enum rarch_display_type type)
|
||||||
{
|
{
|
||||||
video_driver_state_t *video_st = &video_driver_st;
|
video_driver_state_t *video_st = &video_driver_st;
|
||||||
video_display_server_destroy();
|
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||||
|
|
||||||
|
/* Reuse when already and still running */
|
||||||
|
if (current_display_server && runloop_st->flags & RUNLOOP_FLAG_IS_INITED)
|
||||||
|
return video_st->current_display_server_data;
|
||||||
|
else
|
||||||
|
video_display_server_destroy();
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -3279,6 +3285,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
|
|||||||
video_st->flags |= VIDEO_FLAG_STARTED_FULLSCREEN;
|
video_st->flags |= VIDEO_FLAG_STARTED_FULLSCREEN;
|
||||||
else
|
else
|
||||||
video_st->flags &= ~VIDEO_FLAG_STARTED_FULLSCREEN;
|
video_st->flags &= ~VIDEO_FLAG_STARTED_FULLSCREEN;
|
||||||
|
|
||||||
/* Reset video frame count */
|
/* Reset video frame count */
|
||||||
video_st->frame_count = 0;
|
video_st->frame_count = 0;
|
||||||
video_st->frame_drop_count = 0;
|
video_st->frame_drop_count = 0;
|
||||||
|
106
retroarch.c
106
retroarch.c
@ -1405,7 +1405,6 @@ static float audio_driver_monitor_adjust_system_rates(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool video_driver_monitor_adjust_system_rates(
|
static bool video_driver_monitor_adjust_system_rates(
|
||||||
unsigned _video_swap_interval,
|
|
||||||
float timing_skew_hz,
|
float timing_skew_hz,
|
||||||
float video_refresh_rate,
|
float video_refresh_rate,
|
||||||
bool vrr_runloop_enable,
|
bool vrr_runloop_enable,
|
||||||
@ -1444,20 +1443,20 @@ static bool video_driver_monitor_adjust_system_rates(
|
|||||||
static void driver_adjust_system_rates(
|
static void driver_adjust_system_rates(
|
||||||
runloop_state_t *runloop_st,
|
runloop_state_t *runloop_st,
|
||||||
video_driver_state_t *video_st,
|
video_driver_state_t *video_st,
|
||||||
settings_t *settings,
|
settings_t *settings)
|
||||||
bool vrr_runloop_enable,
|
|
||||||
float video_refresh_rate,
|
|
||||||
float audio_max_timing_skew,
|
|
||||||
bool video_adaptive_vsync,
|
|
||||||
unsigned video_swap_interval,
|
|
||||||
unsigned black_frame_insertion,
|
|
||||||
unsigned shader_subframes)
|
|
||||||
{
|
{
|
||||||
struct retro_system_av_info *av_info = &video_st->av_info;
|
struct retro_system_av_info *av_info = &video_st->av_info;
|
||||||
const struct retro_system_timing *info =
|
const struct retro_system_timing *info =
|
||||||
(const struct retro_system_timing*)&av_info->timing;
|
(const struct retro_system_timing*)&av_info->timing;
|
||||||
double input_sample_rate = info->sample_rate;
|
double input_sample_rate = info->sample_rate;
|
||||||
double input_fps = info->fps;
|
double input_fps = info->fps;
|
||||||
|
float video_refresh_rate = settings->floats.video_refresh_rate;
|
||||||
|
float audio_max_timing_skew = settings->floats.audio_max_timing_skew;
|
||||||
|
unsigned video_swap_interval = settings->uints.video_swap_interval;
|
||||||
|
unsigned black_frame_insertion = settings->uints.video_black_frame_insertion;
|
||||||
|
unsigned shader_subframes = settings->uints.video_shader_subframes;
|
||||||
|
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
|
||||||
|
bool video_adaptive_vsync = settings->bools.video_adaptive_vsync;
|
||||||
|
|
||||||
/* Update video swap interval if automatic
|
/* Update video swap interval if automatic
|
||||||
* switching is enabled */
|
* switching is enabled */
|
||||||
@ -1504,7 +1503,6 @@ static void driver_adjust_system_rates(
|
|||||||
video_st->core_hz = input_fps;
|
video_st->core_hz = input_fps;
|
||||||
|
|
||||||
if (!video_driver_monitor_adjust_system_rates(
|
if (!video_driver_monitor_adjust_system_rates(
|
||||||
settings->uints.video_swap_interval,
|
|
||||||
timing_skew_hz,
|
timing_skew_hz,
|
||||||
video_refresh_rate,
|
video_refresh_rate,
|
||||||
vrr_runloop_enable,
|
vrr_runloop_enable,
|
||||||
@ -1625,17 +1623,6 @@ void drivers_init(
|
|||||||
menu_st->flags |= MENU_ST_FLAG_DATA_OWN;
|
menu_st->flags |= MENU_ST_FLAG_DATA_OWN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK))
|
|
||||||
driver_adjust_system_rates(runloop_st, video_st, settings,
|
|
||||||
settings->bools.vrr_runloop_enable,
|
|
||||||
settings->floats.video_refresh_rate,
|
|
||||||
settings->floats.audio_max_timing_skew,
|
|
||||||
settings->bools.video_adaptive_vsync,
|
|
||||||
settings->uints.video_swap_interval,
|
|
||||||
settings->uints.video_black_frame_insertion,
|
|
||||||
settings->uints.video_shader_subframes
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Initialize video driver */
|
/* Initialize video driver */
|
||||||
if (flags & DRIVER_VIDEO_MASK)
|
if (flags & DRIVER_VIDEO_MASK)
|
||||||
{
|
{
|
||||||
@ -1660,31 +1647,9 @@ void drivers_init(
|
|||||||
runloop_st->frame_time_last = 0;
|
runloop_st->frame_time_last = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize audio driver */
|
|
||||||
if (flags & DRIVER_AUDIO_MASK)
|
|
||||||
{
|
|
||||||
audio_driver_init_internal(
|
|
||||||
settings,
|
|
||||||
audio_st->callback.callback != NULL);
|
|
||||||
if ( audio_st->current_audio
|
|
||||||
&& audio_st->current_audio->device_list_new
|
|
||||||
&& audio_st->context_audio_data)
|
|
||||||
audio_st->devices_list = (struct string_list*)
|
|
||||||
audio_st->current_audio->device_list_new(
|
|
||||||
audio_st->context_audio_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_MICROPHONE
|
|
||||||
if (flags & DRIVER_MICROPHONE_MASK)
|
|
||||||
{
|
|
||||||
microphone_driver_init_internal(settings);
|
|
||||||
if (mic_st->driver && mic_st->driver->device_list_new && mic_st->driver_context)
|
|
||||||
mic_st->devices_list = mic_st->driver->device_list_new(mic_st->driver_context);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Regular display refresh rate startup autoswitch based on content av_info */
|
/* Regular display refresh rate startup autoswitch based on content av_info */
|
||||||
if (flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK))
|
if ( flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK)
|
||||||
|
&& !(runloop_st->flags & RUNLOOP_FLAG_IS_INITED))
|
||||||
{
|
{
|
||||||
struct retro_system_av_info *av_info = &video_st->av_info;
|
struct retro_system_av_info *av_info = &video_st->av_info;
|
||||||
float refresh_rate = av_info->timing.fps;
|
float refresh_rate = av_info->timing.fps;
|
||||||
@ -1708,18 +1673,39 @@ void drivers_init(
|
|||||||
bool video_switch_refresh_rate = false;
|
bool video_switch_refresh_rate = false;
|
||||||
|
|
||||||
video_switch_refresh_rate_maybe(&refresh_rate, &video_switch_refresh_rate);
|
video_switch_refresh_rate_maybe(&refresh_rate, &video_switch_refresh_rate);
|
||||||
|
|
||||||
if (video_switch_refresh_rate && video_display_server_set_refresh_rate(refresh_rate))
|
if (video_switch_refresh_rate && video_display_server_set_refresh_rate(refresh_rate))
|
||||||
{
|
|
||||||
int reinit_flags = DRIVER_AUDIO_MASK;
|
|
||||||
video_monitor_set_refresh_rate(refresh_rate);
|
video_monitor_set_refresh_rate(refresh_rate);
|
||||||
/* Audio must reinit after successful rate switch */
|
|
||||||
command_event(CMD_EVENT_REINIT, &reinit_flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adjust rates */
|
||||||
|
if (flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK))
|
||||||
|
driver_adjust_system_rates(runloop_st, video_st, settings);
|
||||||
|
|
||||||
|
/* Initialize audio driver */
|
||||||
|
if (flags & DRIVER_AUDIO_MASK)
|
||||||
|
{
|
||||||
|
audio_driver_init_internal(
|
||||||
|
settings,
|
||||||
|
audio_st->callback.callback != NULL);
|
||||||
|
if ( audio_st->current_audio
|
||||||
|
&& audio_st->current_audio->device_list_new
|
||||||
|
&& audio_st->context_audio_data)
|
||||||
|
audio_st->devices_list = (struct string_list*)
|
||||||
|
audio_st->current_audio->device_list_new(
|
||||||
|
audio_st->context_audio_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MICROPHONE
|
||||||
|
if (flags & DRIVER_MICROPHONE_MASK)
|
||||||
|
{
|
||||||
|
microphone_driver_init_internal(settings);
|
||||||
|
if (mic_st->driver && mic_st->driver->device_list_new && mic_st->driver_context)
|
||||||
|
mic_st->devices_list = mic_st->driver->device_list_new(mic_st->driver_context);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (flags & DRIVER_CAMERA_MASK)
|
if (flags & DRIVER_CAMERA_MASK)
|
||||||
{
|
{
|
||||||
/* Only initialize camera driver if we're ever going to use it. */
|
/* Only initialize camera driver if we're ever going to use it. */
|
||||||
@ -2063,14 +2049,6 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
|
|||||||
video_driver_state_t*video_st = video_state_get_ptr();
|
video_driver_state_t*video_st = video_state_get_ptr();
|
||||||
unsigned
|
unsigned
|
||||||
audio_output_sample_rate = settings->uints.audio_output_sample_rate;
|
audio_output_sample_rate = settings->uints.audio_output_sample_rate;
|
||||||
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
|
|
||||||
float video_refresh_rate = settings->floats.video_refresh_rate;
|
|
||||||
float audio_max_timing_skew = settings->floats.audio_max_timing_skew;
|
|
||||||
bool video_adaptive_vsync = settings->bools.video_adaptive_vsync;
|
|
||||||
unsigned video_swap_interval = settings->uints.video_swap_interval;
|
|
||||||
unsigned
|
|
||||||
black_frame_insertion = settings->uints.video_black_frame_insertion;
|
|
||||||
unsigned shader_subframes = settings->uints.video_shader_subframes;
|
|
||||||
|
|
||||||
video_monitor_set_refresh_rate(*hz);
|
video_monitor_set_refresh_rate(*hz);
|
||||||
|
|
||||||
@ -2079,15 +2057,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
|
|||||||
audio_st->source_ratio_current =
|
audio_st->source_ratio_current =
|
||||||
(double)audio_output_sample_rate / audio_st->input;
|
(double)audio_output_sample_rate / audio_st->input;
|
||||||
|
|
||||||
driver_adjust_system_rates(runloop_st, video_st, settings,
|
driver_adjust_system_rates(runloop_st, video_st, settings);
|
||||||
vrr_runloop_enable,
|
|
||||||
video_refresh_rate,
|
|
||||||
audio_max_timing_skew,
|
|
||||||
video_adaptive_vsync,
|
|
||||||
video_swap_interval,
|
|
||||||
black_frame_insertion,
|
|
||||||
shader_subframes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RARCH_DRIVER_CTL_FIND_FIRST:
|
case RARCH_DRIVER_CTL_FIND_FIRST:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user