From 364d0ff45d27262140adbf5e3c7cdcfb5bcb7a6f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 27 Mar 2024 13:41:38 -0400 Subject: [PATCH] pad: gst_pad_set_offset is only reliable on source pads Setting an offset on sink pads won't repush segment event which means buffer running time won't be adjusted. Better warn about this than being silently not working. Part-of: --- girs/Gst-1.0.gir | 5 ++++- subprojects/gstreamer/gst/gstpad.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/girs/Gst-1.0.gir b/girs/Gst-1.0.gir index 054b9b6ec3..4034125c3b 100644 --- a/girs/Gst-1.0.gir +++ b/girs/Gst-1.0.gir @@ -30985,7 +30985,10 @@ of the peer sink pad, if present. - Set the offset that will be applied to the running time of @pad. + Set the offset that will be applied to the running time of @pad. Upon next +buffer, every sticky events (notably segment) will be pushed again with +their running time adjusted. For that reason this is only reliable on +source pads. diff --git a/subprojects/gstreamer/gst/gstpad.c b/subprojects/gstreamer/gst/gstpad.c index 798b3616b8..6aee9fc87b 100644 --- a/subprojects/gstreamer/gst/gstpad.c +++ b/subprojects/gstreamer/gst/gstpad.c @@ -4014,13 +4014,24 @@ mark_event_not_received (GstPad * pad, PadEvent * ev, gpointer user_data) * @pad: a #GstPad * @offset: the offset * - * Set the offset that will be applied to the running time of @pad. + * Set the offset that will be applied to the running time of @pad. Upon next + * buffer, every sticky events (notably segment) will be pushed again with + * their running time adjusted. For that reason this is only reliable on + * source pads. */ void gst_pad_set_offset (GstPad * pad, gint64 offset) { g_return_if_fail (GST_IS_PAD (pad)); + /* Setting pad offset on a sink pad does not work reliably: + * https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6464 */ + if (GST_PAD_IS_SINK (pad)) { + /* Make it non fatal warning for backward compatibility. */ + GST_WARNING_OBJECT (pad, + "Setting pad offset only works reliably on source pads"); + } + GST_OBJECT_LOCK (pad); /* if nothing changed, do nothing */ if (pad->offset == offset)