Refactor nonblock states.
Preserve nonblock state better across reinits, etc. Try to keep vsync in RGUI.
This commit is contained in:
parent
67a69d0339
commit
f968ee6527
28
driver.c
28
driver.c
|
@ -255,7 +255,12 @@ static void adjust_system_rates(void)
|
||||||
RARCH_LOG("Set audio input rate to: %.2f Hz.\n", g_settings.audio.in_rate);
|
RARCH_LOG("Set audio input rate to: %.2f Hz.\n", g_settings.audio.in_rate);
|
||||||
|
|
||||||
if (driver.video_data)
|
if (driver.video_data)
|
||||||
video_set_nonblock_state_func(!g_settings.video.vsync || g_extern.system.force_nonblock);
|
{
|
||||||
|
if (g_extern.system.force_nonblock)
|
||||||
|
video_set_nonblock_state_func(true);
|
||||||
|
else
|
||||||
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void driver_set_monitor_refresh_rate(float hz)
|
void driver_set_monitor_refresh_rate(float hz)
|
||||||
|
@ -267,7 +272,24 @@ void driver_set_monitor_refresh_rate(float hz)
|
||||||
g_extern.audio_data.orig_src_ratio =
|
g_extern.audio_data.orig_src_ratio =
|
||||||
g_extern.audio_data.src_ratio =
|
g_extern.audio_data.src_ratio =
|
||||||
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
|
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void driver_set_nonblock_state(bool nonblock)
|
||||||
|
{
|
||||||
|
// Only apply non-block-state for video if we're using vsync.
|
||||||
|
if (g_extern.video_active)
|
||||||
|
{
|
||||||
|
bool video_nb = nonblock;
|
||||||
|
if (!g_settings.video.vsync || !g_extern.system.force_nonblock)
|
||||||
|
video_nb = true;
|
||||||
|
video_set_nonblock_state_func(video_nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_extern.audio_active)
|
||||||
|
audio_set_nonblock_state_func(g_settings.audio.sync ? nonblock : true);
|
||||||
|
|
||||||
|
g_extern.audio_data.chunk_size = nonblock ?
|
||||||
|
g_extern.audio_data.nonblock_chunk_size : g_extern.audio_data.block_chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t driver_get_current_framebuffer(void)
|
uintptr_t driver_get_current_framebuffer(void)
|
||||||
|
@ -347,6 +369,10 @@ void init_drivers(void)
|
||||||
g_extern.system.hw_render_callback.context_reset();
|
g_extern.system.hw_render_callback.context_reset();
|
||||||
|
|
||||||
init_audio();
|
init_audio();
|
||||||
|
|
||||||
|
// Keep non-throttled state as good as possible.
|
||||||
|
if (driver.nonblock_state)
|
||||||
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninit_drivers(void)
|
void uninit_drivers(void)
|
||||||
|
|
2
driver.h
2
driver.h
|
@ -416,6 +416,7 @@ typedef struct driver
|
||||||
#endif
|
#endif
|
||||||
bool stdin_claimed;
|
bool stdin_claimed;
|
||||||
bool block_hotkey;
|
bool block_hotkey;
|
||||||
|
bool nonblock_state;
|
||||||
|
|
||||||
// Opaque handles to currently running window.
|
// Opaque handles to currently running window.
|
||||||
// Used by e.g. input drivers which bind to a window.
|
// Used by e.g. input drivers which bind to a window.
|
||||||
|
@ -460,6 +461,7 @@ void init_audio(void);
|
||||||
void uninit_audio(void);
|
void uninit_audio(void);
|
||||||
|
|
||||||
void driver_set_monitor_refresh_rate(float hz);
|
void driver_set_monitor_refresh_rate(float hz);
|
||||||
|
void driver_set_nonblock_state(bool nonblock);
|
||||||
|
|
||||||
// Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
|
// Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
|
||||||
uintptr_t driver_get_current_framebuffer(void);
|
uintptr_t driver_get_current_framebuffer(void);
|
||||||
|
|
|
@ -83,7 +83,10 @@ int main(int argc, char *argv[])
|
||||||
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
|
else if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))
|
||||||
{
|
{
|
||||||
g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT;
|
g_extern.lifecycle_mode_state |= 1ULL << MODE_MENU_PREINIT;
|
||||||
|
// Menu should always run with vsync on.
|
||||||
|
video_set_nonblock_state_func(false);
|
||||||
while (menu_iterate());
|
while (menu_iterate());
|
||||||
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
26
retroarch.c
26
retroarch.c
|
@ -49,38 +49,24 @@
|
||||||
#define RARCH_PERFORMANCE_MODE
|
#define RARCH_PERFORMANCE_MODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To avoid continous switching if we hold the button down, we require that the button must go from pressed, unpressed back to pressed to be able to toggle between then.
|
// To avoid continous switching if we hold the button down, we require that the button must go from pressed,
|
||||||
|
// unpressed back to pressed to be able to toggle between then.
|
||||||
static void check_fast_forward_button(void)
|
static void check_fast_forward_button(void)
|
||||||
{
|
{
|
||||||
bool new_button_state = input_key_pressed_func(RARCH_FAST_FORWARD_KEY);
|
bool new_button_state = input_key_pressed_func(RARCH_FAST_FORWARD_KEY);
|
||||||
bool new_hold_button_state = input_key_pressed_func(RARCH_FAST_FORWARD_HOLD_KEY);
|
bool new_hold_button_state = input_key_pressed_func(RARCH_FAST_FORWARD_HOLD_KEY);
|
||||||
bool update_sync = false;
|
|
||||||
static bool old_button_state = false;
|
static bool old_button_state = false;
|
||||||
static bool old_hold_button_state = false;
|
static bool old_hold_button_state = false;
|
||||||
static bool syncing_state = false;
|
|
||||||
|
|
||||||
if (new_button_state && !old_button_state)
|
if (new_button_state && !old_button_state)
|
||||||
{
|
{
|
||||||
syncing_state = !syncing_state;
|
driver.nonblock_state = !driver.nonblock_state;
|
||||||
update_sync = true;
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
}
|
}
|
||||||
else if (old_hold_button_state != new_hold_button_state)
|
else if (old_hold_button_state != new_hold_button_state)
|
||||||
{
|
{
|
||||||
syncing_state = new_hold_button_state;
|
driver.nonblock_state = new_hold_button_state;
|
||||||
update_sync = true;
|
driver_set_nonblock_state(driver.nonblock_state);
|
||||||
}
|
|
||||||
|
|
||||||
if (update_sync)
|
|
||||||
{
|
|
||||||
// Only apply non-block-state for video if we're using vsync.
|
|
||||||
if (g_extern.video_active && g_settings.video.vsync && !g_extern.system.force_nonblock)
|
|
||||||
video_set_nonblock_state_func(syncing_state);
|
|
||||||
|
|
||||||
if (g_extern.audio_active)
|
|
||||||
audio_set_nonblock_state_func(g_settings.audio.sync ? syncing_state : true);
|
|
||||||
|
|
||||||
g_extern.audio_data.chunk_size =
|
|
||||||
syncing_state ? g_extern.audio_data.nonblock_chunk_size : g_extern.audio_data.block_chunk_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old_button_state = new_button_state;
|
old_button_state = new_button_state;
|
||||||
|
|
Loading…
Reference in New Issue