[0.11] gst-plugins-base: videopool: update for allocator api update

Wim Taymans wtay at kemper.freedesktop.org
Mon Jan 30 04:20:25 PST 2012


Module: gst-plugins-base
Branch: 0.11
Commit: fa400c372b9bea408d691d770301ba0ecbf8ad8a
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=fa400c372b9bea408d691d770301ba0ecbf8ad8a

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Jan 30 13:06:55 2012 +0100

videopool: update for allocator api update

---

 gst-libs/gst/video/gstvideopool.c |   35 ++++++++++++++++++++++++++++-------
 gst-libs/gst/video/gstvideopool.h |    6 +++---
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/gst-libs/gst/video/gstvideopool.c b/gst-libs/gst/video/gstvideopool.c
index d7e0dd1..5d2bb45 100644
--- a/gst-libs/gst/video/gstvideopool.c
+++ b/gst-libs/gst/video/gstvideopool.c
@@ -138,7 +138,7 @@ gst_video_info_align (GstVideoInfo * info, GstVideoAlignment * align)
 /* bufferpool */
 struct _GstVideoBufferPoolPrivate
 {
-  const GstAllocator *allocator;
+  GstAllocator *allocator;
   GstCaps *caps;
   GstVideoInfo info;
   GstVideoAlignment video_align;
@@ -330,6 +330,9 @@ gst_video_buffer_pool_finalize (GObject * object)
   if (priv->caps)
     gst_caps_unref (priv->caps);
 
+  if (priv->allocator)
+    gst_allocator_ref (priv->allocator);
+
   G_OBJECT_CLASS (gst_video_buffer_pool_parent_class)->finalize (object);
 }
 
@@ -339,29 +342,47 @@ gst_video_buffer_pool_finalize (GObject * object)
  *
  * Get the allocator used by @pool to allocate the video memory.
  *
- * Returns: the allocator used for allocating video memory
+ * Returns: (transfer full) the allocator used for allocating video memory.
+ * gst_allocator_unref() after usage.
  */
-const GstAllocator *
+GstAllocator *
 gst_video_buffer_pool_get_allocator (GstVideoBufferPool * pool)
 {
+  GstAllocator *alloc;
+
   g_return_val_if_fail (GST_IS_VIDEO_BUFFER_POOL (pool), NULL);
 
-  return pool->priv->allocator;
+  if ((alloc = pool->priv->allocator))
+    gst_allocator_ref (alloc);
+
+  return alloc;
 }
 
 /**
  * gst_video_buffer_pool_set_allocator:
  * @pool: a #GstVideoBufferPool
- * @allocator: a #GstAllocator
+ * @allocator: (transfer none): a #GstAllocator
  *
  * Set the allocator used to allocate video memory in @pool. The allocator
  * should only be changed by subclasses.
  */
 void
 gst_video_buffer_pool_set_allocator (GstVideoBufferPool * pool,
-    const GstAllocator * allocator)
+    GstAllocator * allocator)
 {
+  GstAllocator *oldalloc;
+  GstVideoBufferPoolPrivate *priv;
+
   g_return_if_fail (GST_IS_VIDEO_BUFFER_POOL (pool));
 
-  pool->priv->allocator = allocator;
+  priv = pool->priv;
+
+  if (allocator)
+    gst_allocator_ref (allocator);
+
+  oldalloc = priv->allocator;
+  priv->allocator = allocator;
+
+  if (oldalloc)
+    gst_allocator_unref (oldalloc);
 }
diff --git a/gst-libs/gst/video/gstvideopool.h b/gst-libs/gst/video/gstvideopool.h
index 73fa742..de76cbf 100644
--- a/gst-libs/gst/video/gstvideopool.h
+++ b/gst-libs/gst/video/gstvideopool.h
@@ -97,9 +97,9 @@ GType             gst_video_buffer_pool_get_type      (void);
 
 GstBufferPool *   gst_video_buffer_pool_new           (void);
 
-const GstAllocator * gst_video_buffer_pool_get_allocator (GstVideoBufferPool *pool);
-void                 gst_video_buffer_pool_set_allocator (GstVideoBufferPool *pool,
-                                                          const GstAllocator *allocator);
+GstAllocator *    gst_video_buffer_pool_get_allocator (GstVideoBufferPool *pool);
+void              gst_video_buffer_pool_set_allocator (GstVideoBufferPool *pool,
+                                                       GstAllocator *allocator);
 
 G_END_DECLS
 



More information about the gstreamer-commits mailing list