From fa400c372b9bea408d691d770301ba0ecbf8ad8a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 30 Jan 2012 13:06:55 +0100 Subject: [PATCH] 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 -- 2.7.4