From 8117ee4fa3e86429c1c22e42e6aed254fe48d819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 20 Jun 2024 15:13:27 +0300 Subject: [PATCH] queue, queue2, multiqueue: Timestamps of gap events must be valid This is checked in gst_event_new_gap() so doesn't have to be checked again here, but simply can be asserted with a g_return_if_fail(). Part-of: --- .../plugins/elements/gstmultiqueue.c | 48 +++++++++---------- .../gstreamer/plugins/elements/gstqueue.c | 38 +++++++-------- .../gstreamer/plugins/elements/gstqueue2.c | 40 ++++++++-------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/subprojects/gstreamer/plugins/elements/gstmultiqueue.c b/subprojects/gstreamer/plugins/elements/gstmultiqueue.c index 5cef9dc9cd..ea20f8b294 100644 --- a/subprojects/gstreamer/plugins/elements/gstmultiqueue.c +++ b/subprojects/gstreamer/plugins/elements/gstmultiqueue.c @@ -1880,36 +1880,36 @@ apply_gap (GstMultiQueue * mq, GstSingleQueue * sq, GstEvent * event, GstClockTime duration; gboolean is_sink = segment == &sq->sink_segment; - GST_MULTI_QUEUE_MUTEX_LOCK (mq); - gst_event_parse_gap (event, ×tamp, &duration); - if (GST_CLOCK_TIME_IS_VALID (timestamp)) { - if (is_sink && !GST_CLOCK_STIME_IS_VALID (sq->sink_start_time)) { - sq->sink_start_time = my_segment_to_running_time (segment, timestamp); - GST_DEBUG_ID (sq->debug_id, "Start time updated to %" GST_STIME_FORMAT, - GST_STIME_ARGS (sq->sink_start_time)); - } + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp)); - if (GST_CLOCK_TIME_IS_VALID (duration)) { - timestamp += duration; - } + GST_MULTI_QUEUE_MUTEX_LOCK (mq); - GST_DEBUG_ID (sq->debug_id, - "%s position updated to %" GST_TIME_FORMAT, - is_sink ? "sink" : "src", GST_TIME_ARGS (timestamp)); - - segment->position = timestamp; - - if (is_sink) - sq->sink_tainted = TRUE; - else - sq->src_tainted = TRUE; - - /* calc diff with other end */ - update_time_level (mq, sq); + if (is_sink && !GST_CLOCK_STIME_IS_VALID (sq->sink_start_time)) { + sq->sink_start_time = my_segment_to_running_time (segment, timestamp); + GST_DEBUG_ID (sq->debug_id, "Start time updated to %" GST_STIME_FORMAT, + GST_STIME_ARGS (sq->sink_start_time)); } + if (GST_CLOCK_TIME_IS_VALID (duration)) { + timestamp += duration; + } + + GST_DEBUG_ID (sq->debug_id, + "%s position updated to %" GST_TIME_FORMAT, + is_sink ? "sink" : "src", GST_TIME_ARGS (timestamp)); + + segment->position = timestamp; + + if (is_sink) + sq->sink_tainted = TRUE; + else + sq->src_tainted = TRUE; + + /* calc diff with other end */ + update_time_level (mq, sq); + GST_MULTI_QUEUE_MUTEX_UNLOCK (mq); gst_multi_queue_post_buffering (mq); } diff --git a/subprojects/gstreamer/plugins/elements/gstqueue.c b/subprojects/gstreamer/plugins/elements/gstqueue.c index eb75b4cfe5..0d9a065e50 100644 --- a/subprojects/gstreamer/plugins/elements/gstqueue.c +++ b/subprojects/gstreamer/plugins/elements/gstqueue.c @@ -608,27 +608,27 @@ apply_gap (GstQueue * queue, GstEvent * event, gst_event_parse_gap (event, ×tamp, &duration); - if (GST_CLOCK_TIME_IS_VALID (timestamp)) { - if (is_sink && !GST_CLOCK_STIME_IS_VALID (queue->sink_start_time)) { - queue->sink_start_time = my_segment_to_running_time (segment, timestamp); - GST_DEBUG_OBJECT (queue, "Start time updated to %" GST_STIME_FORMAT, - GST_STIME_ARGS (queue->sink_start_time)); - } + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp)); - if (GST_CLOCK_TIME_IS_VALID (duration)) { - timestamp += duration; - } - - segment->position = timestamp; - - if (is_sink) - queue->sink_tainted = TRUE; - else - queue->src_tainted = TRUE; - - /* calc diff with other end */ - update_time_level (queue); + if (is_sink && !GST_CLOCK_STIME_IS_VALID (queue->sink_start_time)) { + queue->sink_start_time = my_segment_to_running_time (segment, timestamp); + GST_DEBUG_OBJECT (queue, "Start time updated to %" GST_STIME_FORMAT, + GST_STIME_ARGS (queue->sink_start_time)); } + + if (GST_CLOCK_TIME_IS_VALID (duration)) { + timestamp += duration; + } + + segment->position = timestamp; + + if (is_sink) + queue->sink_tainted = TRUE; + else + queue->src_tainted = TRUE; + + /* calc diff with other end */ + update_time_level (queue); } diff --git a/subprojects/gstreamer/plugins/elements/gstqueue2.c b/subprojects/gstreamer/plugins/elements/gstqueue2.c index f4b6d39cac..f1eeff1fff 100644 --- a/subprojects/gstreamer/plugins/elements/gstqueue2.c +++ b/subprojects/gstreamer/plugins/elements/gstqueue2.c @@ -832,28 +832,28 @@ apply_gap (GstQueue2 * queue, GstEvent * event, gst_event_parse_gap (event, ×tamp, &duration); - if (GST_CLOCK_TIME_IS_VALID (timestamp)) { - if (is_sink && !GST_CLOCK_TIME_IS_VALID (queue->sink_start_time)) { - queue->sink_start_time = gst_segment_to_running_time (segment, - GST_FORMAT_TIME, timestamp); - GST_DEBUG_OBJECT (queue, "Start time updated to %" GST_TIME_FORMAT, - GST_TIME_ARGS (queue->sink_start_time)); - } + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp)); - if (GST_CLOCK_TIME_IS_VALID (duration)) { - timestamp += duration; - } - - segment->position = timestamp; - - if (is_sink) - queue->sink_tainted = TRUE; - else - queue->src_tainted = TRUE; - - /* calc diff with other end */ - update_time_level (queue); + if (is_sink && !GST_CLOCK_TIME_IS_VALID (queue->sink_start_time)) { + queue->sink_start_time = gst_segment_to_running_time (segment, + GST_FORMAT_TIME, timestamp); + GST_DEBUG_OBJECT (queue, "Start time updated to %" GST_TIME_FORMAT, + GST_TIME_ARGS (queue->sink_start_time)); } + + if (GST_CLOCK_TIME_IS_VALID (duration)) { + timestamp += duration; + } + + segment->position = timestamp; + + if (is_sink) + queue->sink_tainted = TRUE; + else + queue->src_tainted = TRUE; + + /* calc diff with other end */ + update_time_level (queue); } static void