pad: Fix printf format when printing hook id
[platform/upstream/gstreamer.git] / gst / gstbufferpool.c
index 133859d..e5c7a58 100644 (file)
@@ -21,6 +21,7 @@
 
 /**
  * SECTION:gstbufferpool
+ * @title: GstBufferPool
  * @short_description: Pool for buffers
  * @see_also: #GstBuffer
  *
@@ -89,9 +90,6 @@
 GST_DEBUG_CATEGORY_STATIC (gst_buffer_pool_debug);
 #define GST_CAT_DEFAULT gst_buffer_pool_debug
 
-#define GST_BUFFER_POOL_GET_PRIVATE(obj)  \
-   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolPrivate))
-
 #define GST_BUFFER_POOL_LOCK(pool)   (g_rec_mutex_lock(&pool->priv->rec_lock))
 #define GST_BUFFER_POOL_UNLOCK(pool) (g_rec_mutex_unlock(&pool->priv->rec_lock))
 
@@ -119,7 +117,7 @@ struct _GstBufferPoolPrivate
 
 static void gst_buffer_pool_finalize (GObject * object);
 
-G_DEFINE_TYPE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
 
 static gboolean default_start (GstBufferPool * pool);
 static gboolean default_stop (GstBufferPool * pool);
@@ -138,8 +136,6 @@ gst_buffer_pool_class_init (GstBufferPoolClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
 
-  g_type_class_add_private (klass, sizeof (GstBufferPoolPrivate));
-
   gobject_class->finalize = gst_buffer_pool_finalize;
 
   klass->start = default_start;
@@ -160,7 +156,7 @@ gst_buffer_pool_init (GstBufferPool * pool)
 {
   GstBufferPoolPrivate *priv;
 
-  priv = pool->priv = GST_BUFFER_POOL_GET_PRIVATE (pool);
+  priv = pool->priv = gst_buffer_pool_get_instance_private (pool);
 
   g_rec_mutex_init (&priv->rec_lock);
 
@@ -211,16 +207,19 @@ gst_buffer_pool_finalize (GObject * object)
  *
  * Creates a new #GstBufferPool instance.
  *
- * Returns: (transfer floating): a new #GstBufferPool instance
+ * Returns: (transfer full): a new #GstBufferPool instance
  */
 GstBufferPool *
 gst_buffer_pool_new (void)
 {
   GstBufferPool *result;
 
-  result = g_object_newv (GST_TYPE_BUFFER_POOL, 0, NULL);
+  result = g_object_new (GST_TYPE_BUFFER_POOL, NULL);
   GST_DEBUG_OBJECT (result, "created new buffer pool");
 
+  /* Clear floating flag */
+  gst_object_ref_sink (result);
+
   return result;
 }
 
@@ -1030,7 +1029,7 @@ gst_buffer_pool_config_get_params (GstStructure * config, GstCaps ** caps,
  *
  * Get the @allocator and @params from @config.
  *
- * Returns: %TRUE, if the values are set. 
+ * Returns: %TRUE, if the values are set.
  */
 gboolean
 gst_buffer_pool_config_get_allocator (GstStructure * config,
@@ -1160,7 +1159,7 @@ default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
       }
     } else {
       /* We're the first thread waiting, we got the wait token and have to
-       * write it again later 
+       * write it again later
        * OR
        * We're a second thread and just consumed the flush token and block all
        * other threads, in which case we must not wait and give it back
@@ -1222,6 +1221,10 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer)
   GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
   GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
 
+  /* if the memory is intact reset the size to the full size */
+  if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY))
+    gst_buffer_resize (buffer, 0, pool->priv->size);
+
   /* remove all metadata without the POOLED flag */
   gst_buffer_foreach_meta (buffer, remove_meta_unpooled, pool);
 }