miniobjects: pass copy, dispose and free function to gst_mini_object_init()
[platform/upstream/gstreamer.git] / gst / gstbufferlist.c
index cc5ddf2..f0b885d 100644 (file)
  * Buffer lists are created with gst_buffer_list_new() and filled with data
  * using a gst_buffer_list_insert().
  *
+ * Buffer lists can be pushed on a srcpad with gst_pad_push_list(). This is
+ * interesting when multiple buffers need to be pushed in one go because it
+ * can reduce the amount of overhead for pushing each buffer individually.
+ *
+ * Last reviewed on 2012-03-28 (0.11.3)
  */
 #include "gst_private.h"
 
@@ -92,17 +97,15 @@ _gst_buffer_list_free (GstBufferList * list)
     gst_buffer_unref (g_array_index (list->array, GstBuffer *, i));
   g_array_free (list->array, TRUE);
 
-  g_slice_free1 (GST_MINI_OBJECT_SIZE (list), list);
+  g_slice_free1 (sizeof (GstBufferList), list);
 }
 
 static void
-gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
+gst_buffer_list_init (GstBufferList * list, guint asize)
 {
   gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type,
-      size);
-
-  list->mini_object.copy = (GstMiniObjectCopyFunction) _gst_buffer_list_copy;
-  list->mini_object.free = (GstMiniObjectFreeFunction) _gst_buffer_list_free;
+      (GstMiniObjectCopyFunction) _gst_buffer_list_copy, NULL,
+      (GstMiniObjectFreeFunction) _gst_buffer_list_free);
 
   list->array = g_array_sized_new (FALSE, FALSE, sizeof (GstBuffer *), asize);
 
@@ -133,7 +136,7 @@ gst_buffer_list_new_sized (guint size)
 
   GST_LOG ("new %p", list);
 
-  gst_buffer_list_init (list, sizeof (GstBufferList), size);
+  gst_buffer_list_init (list, size);
 
   return list;
 }
@@ -184,8 +187,8 @@ gst_buffer_list_length (GstBufferList * list)
  * Call @func with @data for each buffer in @list.
  *
  * @func can modify the passed buffer pointer or its contents. The return value
- * of @func define if this function returns or if the remaining buffers in a
- * group should be skipped.
+ * of @func define if this function returns or if the remaining buffers in
+ * the list should be skipped.
  *
  * Since: 0.10.24
  */
@@ -210,6 +213,7 @@ gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
     if (buf != buf_ret) {
       if (buf_ret == NULL) {
         g_array_remove_index (list->array, i);
+        len--;
       } else {
         g_array_index (list->array, GstBuffer *, i) = buf_ret;
       }
@@ -250,6 +254,13 @@ gst_buffer_list_get (GstBufferList * list, guint idx)
 }
 
 /**
+ * gst_buffer_list_add:
+ * @l: a #GstBufferList
+ * @b: a #GstBuffer
+ *
+ * Append @b at the end of @l.
+ */
+/**
  * gst_buffer_list_insert:
  * @list: a #GstBufferList
  * @idx: the index
@@ -274,6 +285,15 @@ gst_buffer_list_insert (GstBufferList * list, guint idx, GstBuffer * buffer)
   }
 }
 
+/**
+ * gst_buffer_list_remove:
+ * @list: a #GstBufferList
+ * @idx: the index
+ * @length: the amount to remove
+ *
+ * Remove @length buffers starting from @idx in @list. The following buffers are
+ * moved to close the gap.
+ */
 void
 gst_buffer_list_remove (GstBufferList * list, guint idx, guint length)
 {