GNOME Bugzilla – Bug 629553
GstAdapter: timestamp not updated when empty buffer is pushed
Last modified: 2010-09-17 13:27:47 UTC
Created attachment 170182 [details] [review] Proposed patch gst_adapter_push() does not update the timestamp that gets returned by gst_adapter_prev_timestamp() if the size of the buffer that is pushed is zero. If the adapter is empty, it should be OK to think of pushing a zero-size buffer as updating the adapter's timestamp, and setting the distance to the end of the queue to zero. The attached patch adds code for this corner case to gst_adapter_push(). If the buffer's size is zero, and the adapter does not contain any buffers, then the adapter's timestamp is set to the buffer's timestamp, and the distance to the end of the adapter is set to zero. This patch should make more elements able to gracefully handle size zero buffers.
What exactly are you going to use this for? I'm asking because the only use for it (that I can see right now) would be to assign a first timestamp to adapter in case no pushed buffer has timestamps. In that case, a method to assign this timestamp (instead of pushing an empty buffer) would be more appropriate IMO.
I'm working with an element that a colleague wrote, that implements a filter that has a fixed latency. Its chain() routine immediately accepts each buffer and puts it into an adapter. Timestamps for outgoing buffers are computed with the help of gst_adapter_prev_timestamp(). This element also has multiple sink pads. The haphazard method by which we have synchronized the sink pads occasionally results in zero-size buffers at the start of the stream. This isn't incorrect, it's just silly. A method of assigning that timestamp would be acceptable, although it would be nice if GStreamer library functions that manipulate buffers could handle zero-sized buffers.
(In reply to comment #2) > A method of assigning that timestamp would be acceptable, although it would be > nice if GStreamer library functions that manipulate buffers could handle > zero-sized buffers. It really needs to handle and store the 0 sized buffers or else pushing a 0 sized buffer (with timestamp) in a non-empty adapter followed by a buffer without a timestamp, would not apply the timestamp to the last buffer.
commit 1dde3cb4407ce28db88688fc8690fdc1f147cee7 Author: Wim Taymans <wim.taymans@collabora.co.uk> Date: Fri Sep 17 12:40:12 2010 +0200 adapter: add support for 0 sized buffers Add support for 0 sized buffers. This is interesting in combination with the timestamp functions. Fixes #629553