From bc19f551296c675dbc01e63cdaf33a7edb588ec0 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 24 Jan 2023 12:27:06 -0300 Subject: [PATCH] screen-cast/monitor-src: Record frames with presentation time Pass the timestamp of the frame as the target timestamp of the record. This makes the rudimentary frame throttling mechanism inside MetaScreenCastStreamSrc work with the timing variability that dynamic dispatch times introduced. Part-of: --- .../meta-screen-cast-monitor-stream-src.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 6bcffd9a5..efb458067 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -160,14 +160,20 @@ stage_painted (MetaStage *stage, MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src); MetaScreenCastRecordResult record_result; MetaScreenCastRecordFlag flags; + int64_t presentation_time_us; if (monitor_src->maybe_record_idle_id) return; + if (!clutter_frame_get_target_presentation_time (frame, &presentation_time_us)) + presentation_time_us = g_get_monotonic_time (); + flags = META_SCREEN_CAST_RECORD_FLAG_DMABUF_ONLY; - record_result = meta_screen_cast_stream_src_maybe_record_frame (src, - flags, - NULL); + record_result = + meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (src, + flags, + NULL, + presentation_time_us); if (!(record_result & META_SCREEN_CAST_RECORD_RESULT_RECORDED_FRAME)) { @@ -189,6 +195,7 @@ before_stage_painted (MetaStage *stage, META_SCREEN_CAST_MONITOR_STREAM_SRC (user_data); MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src); MetaScreenCastRecordFlag flags; + int64_t presentation_time_us; if (monitor_src->maybe_record_idle_id) return; @@ -196,8 +203,14 @@ before_stage_painted (MetaStage *stage, if (!clutter_stage_view_peek_scanout (view)) return; + if (!clutter_frame_get_target_presentation_time (frame, &presentation_time_us)) + presentation_time_us = g_get_monotonic_time (); + flags = META_SCREEN_CAST_RECORD_FLAG_DMABUF_ONLY; - meta_screen_cast_stream_src_maybe_record_frame (src, flags, NULL); + meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (src, + flags, + NULL, + presentation_time_us); } static gboolean