Add delay to savestate notifications (#14514)

This commit is contained in:
sonninnos 2022-10-15 12:29:07 +03:00 committed by GitHub
parent 74d7aa3691
commit bbd6c0ae9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 9 deletions

View File

@ -1500,6 +1500,7 @@ void gfx_widgets_frame(void *data)
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_display_ctx_driver_t *dispctx= p_disp->dispctx;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)video_info->widgets_userdata;
bool fps_show = video_info->fps_show;
bool framecount_show = video_info->framecount_show;
bool memory_show = video_info->memory_show;
bool core_status_msg_show = video_info->core_status_msg_show;
@ -1507,12 +1508,12 @@ void gfx_widgets_frame(void *data)
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
bool widgets_is_paused = video_info->widgets_is_paused;
bool fps_show = video_info->fps_show;
bool widgets_is_fastforwarding = video_info->widgets_is_fast_forwarding;
bool widgets_is_rewinding = video_info->widgets_is_rewinding;
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
bool menu_screensaver_active = video_info->menu_screensaver_active;
bool notifications_hidden = video_info->notifications_hidden;
bool notifications_hidden = video_info->notifications_hidden ||
video_info->msg_queue_delay;
int top_right_x_advance = video_width;
p_dispwidget->gfx_widgets_frame_count++;

View File

@ -2832,18 +2832,19 @@ VIDEO_FLAG_WIDGETS_FAST_FORWARD;
video_info->overlay_behind_menu = false;
#endif
video_info->msg_queue_delay = runloop_st->msg_queue_delay;
video_info->runloop_is_paused = runloop_st->flags & RUNLOOP_FLAG_PAUSED;
video_info->runloop_is_slowmotion = runloop_st->flags & RUNLOOP_FLAG_SLOWMOTION;
video_info->fastforward_frameskip = settings->bools.fastforward_frameskip;
video_info->input_driver_nonblock_state = input_st ?
(input_st->flags & INP_FLAG_NONBLOCKING) : false;
(input_st->flags & INP_FLAG_NONBLOCKING) : false;
video_info->input_driver_grab_mouse_state = (input_st->flags &
INP_FLAG_GRAB_MOUSE_STATE);
video_info->disp_userdata = disp_get_ptr();
video_info->userdata =
VIDEO_DRIVER_GET_PTR_INTERNAL(video_st);
VIDEO_DRIVER_GET_PTR_INTERNAL(video_st);
#ifdef HAVE_THREADS
VIDEO_DRIVER_THREADED_UNLOCK(video_st, is_threaded);
@ -3958,7 +3959,9 @@ void video_driver_frame(const void *data, unsigned width,
}
#endif
if (runloop_st->msg_queue_size > 0)
if (runloop_st->msg_queue_delay > 0)
runloop_st->msg_queue_delay--;
else if (runloop_st->msg_queue_size > 0)
{
/* If widgets are currently enabled, then
* messages were pushed to the queue before
@ -3970,12 +3973,12 @@ void video_driver_frame(const void *data, unsigned width,
if (widgets_active)
{
msg_queue_entry_t msg_entry;
bool msg_found = false;
bool msg_found = false;
RUNLOOP_MSG_QUEUE_LOCK(runloop_st);
msg_found = msg_queue_extract(
&runloop_st->msg_queue, &msg_entry);
runloop_st->msg_queue_size = msg_queue_size(
runloop_st->msg_queue_size = msg_queue_size(
&runloop_st->msg_queue);
RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st);
@ -4002,7 +4005,8 @@ void video_driver_frame(const void *data, unsigned width,
const char *msg = NULL;
RUNLOOP_MSG_QUEUE_LOCK(runloop_st);
msg = msg_queue_pull(&runloop_st->msg_queue);
runloop_st->msg_queue_size = msg_queue_size(&runloop_st->msg_queue);
runloop_st->msg_queue_size = msg_queue_size(&runloop_st->msg_queue);
if (msg)
strlcpy(video_driver_msg, msg, sizeof(video_driver_msg));
RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st);

View File

@ -471,6 +471,7 @@ typedef struct video_frame_info
unsigned black_frame_insertion;
unsigned fps_update_interval;
unsigned memory_update_interval;
unsigned msg_queue_delay;
float menu_wallpaper_opacity;
float menu_framebuffer_opacity;

View File

@ -246,6 +246,7 @@ struct runloop
runloop_core_status_msg_t core_status_msg;
unsigned msg_queue_delay;
unsigned pending_windowed_scale;
unsigned max_frames;
unsigned audio_latency;

View File

@ -1324,7 +1324,13 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
state->flags |= (SAVE_TASK_FLAG_AUTOSAVE |
SAVE_TASK_FLAG_MUTE);
if (settings->bools.savestate_thumbnail_enable)
state->flags |= SAVE_TASK_FLAG_THUMBNAIL_ENABLE;
{
/* Delay OSD messages and widgets for a few frames
* to prevent GPU screenshots from having notifications */
runloop_state_t *runloop_st = runloop_state_get_ptr();
runloop_st->msg_queue_delay = 10;
state->flags |= SAVE_TASK_FLAG_THUMBNAIL_ENABLE;
}
state->state_slot = settings->ints.state_slot;
if (video_driver_cached_frame_has_valid_framebuffer())
state->flags |= SAVE_TASK_FLAG_HAS_VALID_FB;