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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
This commit is contained in:
Georges Basile Stavracas Neto 2023-01-24 12:27:06 -03:00 committed by Robert Mader
parent bc2f1145d8
commit bc19f55129

View File

@ -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,
record_result =
meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (src,
flags,
NULL);
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