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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6464>
This commit is contained in:
Xavier Claessens 2024-03-27 13:41:38 -04:00 committed by GStreamer Marge Bot
parent e7598ed521
commit 364d0ff45d
2 changed files with 16 additions and 2 deletions

View file

@ -30985,7 +30985,10 @@ of the peer sink pad, if present.</doc>
</parameters>
</method>
<method name="set_offset" c:identifier="gst_pad_set_offset">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpad.c">Set the offset that will be applied to the running time of @pad.</doc>
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpad.c">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.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstpad.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>

View file

@ -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)