commit bbca427403a71bb2ad1dc57a7a6b1ab9056fec41
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Fri Aug 17 19:16:48 2012

    adapter: always clear buffer flags, metas and timestamps
    
    gst_adapter_take_buffer sometimes returns a reference on the input
    buffer, sometimes copies a buffer region and sometimes creates a new
    buffer with merged memory.
    
    Make behaviour consistent by always returning a buffer with no
    timestamps or metas, and flags cleared.

diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c
index 899cb98..7dccd38 100644
--- a/libs/gst/base/gstadapter.c
+++ b/libs/gst/base/gstadapter.c
@@ -749,16 +749,12 @@ gst_adapter_take_buffer (GstAdapter * adapter, gsize nbytes)
   skip = adapter->skip;
   hsize = gst_buffer_get_size (cur);
 
-  /* our head buffer has enough data left, return it */
-  if (skip == 0 && hsize == nbytes) {
-    GST_LOG_OBJECT (adapter, "providing buffer of %" G_GSIZE_FORMAT " bytes"
-        " as head buffer", nbytes);
-    buffer = gst_buffer_ref (cur);
-    goto done;
-  } else if (hsize >= nbytes + skip) {
+  /* our head buffer has enough data left, return a copy with
+   * timestamps, metas and flags removed. */
+  if (hsize >= nbytes + skip) {
     GST_LOG_OBJECT (adapter, "providing buffer of %" G_GSIZE_FORMAT " bytes"
         " via region copy", nbytes);
-    buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, nbytes);
+    buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_MEMORY, skip, nbytes);
     goto done;
   }
 #if 0
@@ -769,7 +765,8 @@ gst_adapter_take_buffer (GstAdapter * adapter, gsize nbytes)
     if (gst_buffer_get_size (cur) >= nbytes + skip) {
       GST_LOG_OBJECT (adapter, "providing buffer of %" G_GSIZE_FORMAT " bytes"
           " via sub-buffer", nbytes);
-      buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, nbytes);
+      buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_MEMORY,
+          skip, nbytes);
       goto done;
     }
   }
