After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629553 - GstAdapter: timestamp not updated when empty buffer is pushed
GstAdapter: timestamp not updated when empty buffer is pushed
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal normal
: 0.10.31
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-09-13 18:17 UTC by Leo Singer
Modified: 2010-09-17 13:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (604 bytes, patch)
2010-09-13 18:17 UTC, Leo Singer
none Details | Review

Description Leo Singer 2010-09-13 18:17:45 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.
Comment 1 Wim Taymans 2010-09-14 09:06:44 UTC
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.
Comment 2 Leo Singer 2010-09-14 15:32:49 UTC
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.
Comment 3 Wim Taymans 2010-09-17 09:14:07 UTC
(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.
Comment 4 Wim Taymans 2010-09-17 13:27:47 UTC
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