2 * Copyright (C) 2010 Wim Taymans <wim.taymans@gmail.com>
4 * gstbufferpool.c: GstBufferPool baseclass
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * SECTION:gstbufferpool
24 * @short_description: Pool for buffers
25 * @see_also: #GstBuffer
29 #include "gst_private.h"
35 #include <sys/types.h>
40 #include "gstbufferpool.h"
42 GST_DEBUG_CATEGORY_STATIC (gst_buffer_pool_debug);
43 #define GST_CAT_DEFAULT gst_buffer_pool_debug
45 #define GST_BUFFER_POOL_GET_PRIVATE(obj) \
46 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolPrivate))
48 #define GST_BUFFER_POOL_LOCK(pool) (g_static_rec_mutex_lock(&pool->priv->rec_lock))
49 #define GST_BUFFER_POOL_UNLOCK(pool) (g_static_rec_mutex_unlock(&pool->priv->rec_lock))
51 struct _GstBufferPoolPrivate
53 GStaticRecMutex rec_lock;
67 static void gst_buffer_pool_finalize (GObject * object);
69 G_DEFINE_TYPE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
71 static gboolean default_start (GstBufferPool * pool);
72 static gboolean default_stop (GstBufferPool * pool);
73 static gboolean default_set_config (GstBufferPool * pool,
74 GstStructure * config);
75 static GstFlowReturn default_alloc_buffer (GstBufferPool * pool,
76 GstBuffer ** buffer, GstBufferPoolParams * params);
77 static GstFlowReturn default_acquire_buffer (GstBufferPool * pool,
78 GstBuffer ** buffer, GstBufferPoolParams * params);
79 static void default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
80 GstBufferPoolParams * params);
81 static void default_free_buffer (GstBufferPool * pool, GstBuffer * buffer);
82 static void default_release_buffer (GstBufferPool * pool, GstBuffer * buffer);
85 gst_buffer_pool_class_init (GstBufferPoolClass * klass)
87 GObjectClass *gobject_class = (GObjectClass *) klass;
89 g_type_class_add_private (klass, sizeof (GstBufferPoolPrivate));
91 gobject_class->finalize = gst_buffer_pool_finalize;
93 klass->start = default_start;
94 klass->stop = default_stop;
95 klass->set_config = default_set_config;
96 klass->acquire_buffer = default_acquire_buffer;
97 klass->reset_buffer = default_reset_buffer;
98 klass->alloc_buffer = default_alloc_buffer;
99 klass->release_buffer = default_release_buffer;
100 klass->free_buffer = default_free_buffer;
102 GST_DEBUG_CATEGORY_INIT (gst_buffer_pool_debug, "bufferpool", 0,
107 gst_buffer_pool_init (GstBufferPool * pool)
109 pool->priv = GST_BUFFER_POOL_GET_PRIVATE (pool);
111 g_static_rec_mutex_init (&pool->priv->rec_lock);
113 pool->poll = gst_poll_new_timer ();
114 pool->queue = gst_atomic_queue_new (10);
115 pool->flushing = TRUE;
116 pool->active = FALSE;
117 pool->configured = FALSE;
118 pool->started = FALSE;
119 pool->config = gst_structure_id_empty_new (GST_QUARK (BUFFER_POOL_CONFIG));
120 gst_buffer_pool_config_set (pool->config, NULL, 0, 0, 0, 0, 1);
122 GST_DEBUG_OBJECT (pool, "created");
126 gst_buffer_pool_finalize (GObject * object)
130 pool = GST_BUFFER_POOL_CAST (object);
132 GST_DEBUG_OBJECT (pool, "finalize");
134 gst_buffer_pool_set_active (pool, FALSE);
135 gst_atomic_queue_unref (pool->queue);
136 gst_poll_free (pool->poll);
137 gst_structure_free (pool->config);
138 g_static_rec_mutex_free (&pool->priv->rec_lock);
140 G_OBJECT_CLASS (gst_buffer_pool_parent_class)->finalize (object);
144 * gst_buffer_pool_new:
146 * Creates a new #GstBufferPool instance.
148 * Returns: a new #GstBufferPool instance
151 gst_buffer_pool_new (void)
153 GstBufferPool *result;
155 result = g_object_newv (GST_TYPE_BUFFER_POOL, 0, NULL);
156 GST_DEBUG_OBJECT (result, "created new buffer pool");
162 default_alloc_buffer (GstBufferPool * pool, GstBuffer ** buffer,
163 GstBufferPoolParams * params)
165 GstBufferPoolPrivate *priv = pool->priv;
168 *buffer = gst_buffer_new ();
170 mem = gst_allocator_alloc (NULL, priv->size + priv->prefix, priv->align);
171 gst_memory_resize (mem, priv->prefix, priv->size);
172 gst_buffer_take_memory (*buffer, -1, mem);
177 /* the default implementation for preallocating the buffers
180 default_start (GstBufferPool * pool)
183 GstBufferPoolPrivate *priv = pool->priv;
184 GstBufferPoolClass *pclass;
186 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
188 /* no alloc function, error */
189 if (G_UNLIKELY (pclass->alloc_buffer == NULL))
192 /* we need to prealloc buffers */
193 for (i = 0; i < priv->min_buffers; i++) {
196 if (pclass->alloc_buffer (pool, &buffer, NULL) != GST_FLOW_OK)
199 GST_LOG_OBJECT (pool, "prealloced buffer %d: %p", i, buffer);
200 /* release to the queue, we call the vmethod directly, we don't need to do
201 * the other refcount handling right now. */
202 if (G_LIKELY (pclass->release_buffer))
203 pclass->release_buffer (pool, buffer);
210 GST_WARNING_OBJECT (pool, "no alloc function");
215 GST_WARNING_OBJECT (pool, "alloc function failed");
220 /* must be called with the lock */
222 do_start (GstBufferPool * pool)
224 if (!pool->started) {
225 GstBufferPoolClass *pclass;
227 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
229 GST_LOG_OBJECT (pool, "starting");
230 /* start the pool, subclasses should allocate buffers and put them
232 if (G_LIKELY (pclass->start)) {
233 if (!pclass->start (pool))
236 pool->started = TRUE;
243 default_free_buffer (GstBufferPool * pool, GstBuffer * buffer)
245 gst_buffer_unref (buffer);
248 /* must be called with the lock */
250 default_stop (GstBufferPool * pool)
253 GstBufferPoolClass *pclass;
255 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
258 while ((buffer = gst_atomic_queue_pop (pool->queue))) {
259 GST_LOG_OBJECT (pool, "freeing %p", buffer);
260 gst_poll_read_control (pool->poll);
262 if (G_LIKELY (pclass->free_buffer))
263 pclass->free_buffer (pool, buffer);
268 /* must be called with the lock */
270 do_stop (GstBufferPool * pool)
273 GstBufferPoolClass *pclass;
275 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
277 GST_LOG_OBJECT (pool, "stopping");
278 if (G_LIKELY (pclass->stop)) {
279 if (!pclass->stop (pool))
282 pool->started = FALSE;
288 * gst_buffer_pool_set_active:
289 * @pool: a #GstBufferPool
290 * @active: the new active state
292 * Control the active state of @pool. When the pool is active, new calls to
293 * gst_buffer_pool_acquire_buffer() will return with GST_FLOW_WRONG_STATE.
295 * Returns: %FALSE when the pool was not configured or when preallocation of the
299 gst_buffer_pool_set_active (GstBufferPool * pool, gboolean active)
303 g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
305 GST_LOG_OBJECT (pool, "active %d", active);
307 GST_BUFFER_POOL_LOCK (pool);
308 /* just return if we are already in the right state */
309 if (pool->active == active)
312 /* we need to be configured */
313 if (!pool->configured)
317 if (!do_start (pool))
320 /* unset the flushing state now */
321 gst_poll_read_control (pool->poll);
322 g_atomic_int_set (&pool->flushing, FALSE);
326 /* set to flushing first */
327 g_atomic_int_set (&pool->flushing, TRUE);
328 gst_poll_write_control (pool->poll);
330 /* when all buffers are in the pool, free them. Else they will be
331 * freed when they are released */
332 outstanding = g_atomic_int_get (&pool->outstanding);
333 GST_LOG_OBJECT (pool, "outstanding buffers %d", outstanding);
334 if (outstanding == 0) {
339 pool->active = active;
340 GST_BUFFER_POOL_UNLOCK (pool);
346 GST_DEBUG_OBJECT (pool, "pool was in the right state");
347 GST_BUFFER_POOL_UNLOCK (pool);
352 GST_ERROR_OBJECT (pool, "pool was not configured");
353 GST_BUFFER_POOL_UNLOCK (pool);
358 GST_ERROR_OBJECT (pool, "start failed");
359 GST_BUFFER_POOL_UNLOCK (pool);
364 GST_WARNING_OBJECT (pool, "stop failed");
365 GST_BUFFER_POOL_UNLOCK (pool);
371 default_set_config (GstBufferPool * pool, GstStructure * config)
373 GstBufferPoolPrivate *priv = pool->priv;
375 guint size, min_buffers, max_buffers;
378 /* parse the config and keep around */
379 if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers,
380 &max_buffers, &prefix, &align))
383 GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config);
386 priv->min_buffers = min_buffers;
387 priv->max_buffers = max_buffers;
388 priv->prefix = prefix;
395 GST_WARNING_OBJECT (pool, "invalid config %" GST_PTR_FORMAT, config);
401 * gst_buffer_pool_set_config:
402 * @pool: a #GstBufferPool
403 * @config: a #GstStructure
405 * Set the configuration of the pool. The pool must be inactive and all buffers
406 * allocated form this pool must be returned or else this function will do
407 * nothing and return FALSE.
409 * @config is a #GstStructure that contains the configuration parameters for
410 * the pool. A default and mandatory set of parameters can be configured with
411 * gst_buffer_pool_config_set(). This function takes ownership of @config.
413 * Returns: TRUE when the configuration could be set.
416 gst_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
419 GstBufferPoolClass *pclass;
421 g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
422 g_return_val_if_fail (config != NULL, FALSE);
424 GST_BUFFER_POOL_LOCK (pool);
425 /* can't change the settings when active */
429 /* we can't change when outstanding buffers */
430 if (g_atomic_int_get (&pool->outstanding) != 0)
431 goto have_outstanding;
433 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
435 /* set the new config */
436 if (G_LIKELY (pclass->set_config))
437 result = pclass->set_config (pool, config);
443 gst_structure_free (pool->config);
444 pool->config = config;
446 /* now we are configured */
447 pool->configured = TRUE;
449 GST_BUFFER_POOL_UNLOCK (pool);
456 GST_WARNING_OBJECT (pool, "can't change config, we are active");
457 GST_BUFFER_POOL_UNLOCK (pool);
462 GST_WARNING_OBJECT (pool, "can't change config, have outstanding buffers");
463 GST_BUFFER_POOL_UNLOCK (pool);
469 * gst_buffer_pool_get_config:
470 * @pool: a #GstBufferPool
472 * Get a copy of the current configuration of the pool. This configuration
473 * can either be modified and used for the gst_buffer_pool_set_config() call
474 * or it must be freed after usage.
476 * Returns: a copy of the current configuration of @pool. use
477 * gst_structure_free() after usage or gst_buffer_pool_set_config().
480 gst_buffer_pool_get_config (GstBufferPool * pool)
482 GstStructure *result;
484 g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), NULL);
486 GST_BUFFER_POOL_UNLOCK (pool);
487 result = gst_structure_copy (pool->config);
488 GST_BUFFER_POOL_UNLOCK (pool);
493 static const gchar *empty_meta[] = { NULL };
496 * gst_buffer_pool_get_metas:
497 * @pool: a #GstBufferPool
499 * Get a NULL terminated array of string with supported #GstMeta apis for
500 * @pool. The requested api would typically be added to the config with
501 * gst_buffer_pool_config_add_meta().
503 * Returns: a NULL terminated array of strings.
506 gst_buffer_pool_get_metas (GstBufferPool * pool)
508 GstBufferPoolClass *pclass;
509 const gchar **result;
511 g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), NULL);
513 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
515 if (G_LIKELY (pclass->get_metas))
516 result = pclass->get_metas (pool);
524 * gst_buffer_pool_config_set:
525 * @config: a #GstBufferPool configuration
526 * @caps: caps for the buffers
527 * @size: the size of each buffer, not including prefix
528 * @min_buffers: the minimum amount of buffers to allocate.
529 * @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
530 * @prefix: prefix each buffer with this many bytes
531 * @align: alignment of the buffer data.
533 * Configure @config with the given parameters.
536 gst_buffer_pool_config_set (GstStructure * config, const GstCaps * caps,
537 guint size, guint min_buffers, guint max_buffers, guint prefix, guint align)
539 g_return_if_fail (config != NULL);
541 gst_structure_id_set (config,
542 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
543 GST_QUARK (SIZE), G_TYPE_UINT, size,
544 GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
545 GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
546 GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
547 GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
551 * gst_buffer_pool_config_add_meta:
552 * @config: a #GstBufferPool configuration
553 * @api: an API to add
555 * Adds the metadata api to @config. This will instruct the @bufferpool to use
556 * the specified metadata api on the buffers that it allocates.
558 * The supported API by @pool can be retrieved with gst_buffer_pool_get_metas().
561 gst_buffer_pool_config_add_meta (GstStructure * config, const gchar * api)
565 GValue api_value = { 0 };
567 g_return_if_fail (config != NULL);
569 value = gst_structure_id_get_value (config, GST_QUARK (META));
571 array = (GValueArray *) g_value_get_boxed (value);
573 GValue new_array_val = { 0, };
575 array = g_value_array_new (0);
577 g_value_init (&new_array_val, G_TYPE_VALUE_ARRAY);
578 g_value_take_boxed (&new_array_val, array);
580 gst_structure_id_take_value (config, GST_QUARK (META), &new_array_val);
583 g_value_init (&api_value, G_TYPE_STRING);
584 g_value_set_string (&api_value, api);
585 g_value_array_append (array, &api_value);
586 g_value_unset (&api_value);
590 * gst_buffer_pool_config_n_metas:
591 * @config: a #GstBufferPool configuration
593 * Retrieve the number of values currently stored in the
594 * meta API array of the @config structure.
596 * Returns: the metadata API array size as a #guint.
599 gst_buffer_pool_config_n_metas (GstStructure * config)
605 g_return_val_if_fail (config != NULL, 0);
607 value = gst_structure_id_get_value (config, GST_QUARK (META));
609 array = (GValueArray *) g_value_get_boxed (value);
610 size = array->n_values;
616 * gst_buffer_pool_config_get_meta:
617 * @config: a #GstBufferPool configuration
618 * @index: position in the metadata API array to read
620 * Parse an available @config and get the metadata API
621 * at @index of the metadata API array.
623 * Returns: a #gchar of the metadata API at @index.
626 gst_buffer_pool_config_get_meta (GstStructure * config, guint index)
629 const gchar *ret = NULL;
631 g_return_val_if_fail (config != NULL, 0);
633 value = gst_structure_id_get_value (config, GST_QUARK (META));
638 meta = (GValueArray *) g_value_get_boxed (value);
639 api_value = g_value_array_get_nth (meta, index);
642 ret = g_value_get_string (api_value);
648 * gst_buffer_pool_config_has_meta:
649 * @config: a #GstBufferPool configuration
650 * @api: a metadata api
652 * Check if @config contains @api metadata.
654 * Returns: TRUE if the metadata array contain @api.
657 gst_buffer_pool_config_has_meta (GstStructure * config, const gchar * api)
661 g_return_val_if_fail (config != NULL, 0);
663 value = gst_structure_id_get_value (config, GST_QUARK (META));
669 array = (GValueArray *) g_value_get_boxed (value);
670 for (i = 0; i < array->n_values; i++) {
671 api_value = g_value_array_get_nth (array, i);
672 if (!strcmp (api, g_value_get_string (api_value)))
680 * gst_buffer_pool_config_get:
681 * @config: a #GstBufferPool configuration
682 * @caps: the caps of buffers
683 * @size: the size of each buffer, not including prefix
684 * @min_buffers: the minimum amount of buffers to allocate.
685 * @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
686 * @prefix: prefix each buffer with this many bytes
687 * @align: alignment of the buffer data.
689 * Get the configuration values from @config.
692 gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps,
693 guint * size, guint * min_buffers, guint * max_buffers, guint * prefix,
696 g_return_val_if_fail (config != NULL, FALSE);
698 return gst_structure_id_get (config,
699 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
700 GST_QUARK (SIZE), G_TYPE_UINT, size,
701 GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
702 GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
703 GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
704 GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
708 default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
709 GstBufferPoolParams * params)
711 GstFlowReturn result;
712 GstBufferPoolClass *pclass;
713 GstBufferPoolPrivate *priv = pool->priv;
715 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
718 if (G_UNLIKELY (g_atomic_int_get (&pool->flushing)))
721 /* try to get a buffer from the queue */
722 *buffer = gst_atomic_queue_pop (pool->queue);
723 if (G_LIKELY (*buffer)) {
724 gst_poll_read_control (pool->poll);
725 result = GST_FLOW_OK;
726 GST_LOG_OBJECT (pool, "acquired buffer %p", *buffer);
731 if (priv->max_buffers == 0) {
732 /* no max_buffers, we allocate some more */
733 if (G_LIKELY (pclass->alloc_buffer)) {
734 result = pclass->alloc_buffer (pool, buffer, params);
736 result = GST_FLOW_NOT_SUPPORTED;
737 GST_LOG_OBJECT (pool, "alloc buffer %p", *buffer);
741 /* check if we need to wait */
742 if (params && (params->flags & GST_BUFFER_POOL_FLAG_DONTWAIT)) {
743 GST_LOG_OBJECT (pool, "no more buffers");
744 result = GST_FLOW_UNEXPECTED;
749 GST_LOG_OBJECT (pool, "waiting for free buffers");
750 gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE);
758 GST_DEBUG_OBJECT (pool, "we are flushing");
759 return GST_FLOW_WRONG_STATE;
764 dec_outstanding (GstBufferPool * pool)
766 if (g_atomic_int_dec_and_test (&pool->outstanding)) {
767 /* all buffers are returned to the pool, see if we need to free them */
768 if (g_atomic_int_get (&pool->flushing)) {
769 /* take the lock so that set_active is not run concurrently */
770 GST_BUFFER_POOL_LOCK (pool);
771 /* recheck the flushing state in the lock, the pool could have been
772 * set to active again */
773 if (g_atomic_int_get (&pool->flushing))
776 GST_BUFFER_POOL_UNLOCK (pool);
782 default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
783 GstBufferPoolParams * params)
785 GST_BUFFER_FLAGS (buffer) = 0;
787 GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
788 GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
789 GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
790 GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
794 * gst_buffer_pool_acquire_buffer:
795 * @pool: a #GstBufferPool
796 * @buffer: a location for a #GstBuffer
797 * @params: parameters.
799 * Acquire a buffer from @pool. @buffer should point to a memory location that
800 * can hold a pointer to the new buffer.
802 * @params can be NULL or contain optional parameters to influence the allocation.
804 * Returns: a #GstFlowReturn such as GST_FLOW_WRONG_STATE when the pool is
808 gst_buffer_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
809 GstBufferPoolParams * params)
811 GstBufferPoolClass *pclass;
812 GstFlowReturn result;
814 g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), GST_FLOW_ERROR);
815 g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
817 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
819 /* assume we'll have one more outstanding buffer we need to do that so
820 * that concurrent set_active doesn't clear the buffers */
821 g_atomic_int_inc (&pool->outstanding);
823 if (G_LIKELY (pclass->acquire_buffer))
824 result = pclass->acquire_buffer (pool, buffer, params);
826 result = GST_FLOW_NOT_SUPPORTED;
828 if (G_LIKELY (result == GST_FLOW_OK)) {
829 /* all buffers from the pool point to the pool and have the refcount of the
830 * pool incremented */
831 (*buffer)->pool = gst_object_ref (pool);
832 /* now reset the buffer when needed */
833 if (G_LIKELY (pclass->reset_buffer))
834 pclass->reset_buffer (pool, *buffer, params);
836 dec_outstanding (pool);
843 default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
845 /* keep it around in our queue */
846 GST_LOG_OBJECT (pool, "released buffer %p", buffer);
847 gst_atomic_queue_push (pool->queue, buffer);
848 gst_poll_write_control (pool->poll);
852 * gst_buffer_pool_release_buffer:
853 * @pool: a #GstBufferPool
854 * @buffer: a #GstBuffer
856 * Release @buffer to @pool. @buffer should have previously been allocated from
857 * @pool with gst_buffer_pool_acquire_buffer().
859 * This function is usually called automatically when the last ref on @buffer
863 gst_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
865 GstBufferPoolClass *pclass;
867 g_return_if_fail (GST_IS_BUFFER_POOL (pool));
868 g_return_if_fail (buffer != NULL);
870 /* check that the buffer is ours, all buffers returned to the pool have the
871 * pool member set to NULL and the pool refcount decreased */
872 if (!g_atomic_pointer_compare_and_exchange ((gpointer *) & buffer->pool,
876 pclass = GST_BUFFER_POOL_GET_CLASS (pool);
878 if (G_LIKELY (pclass->release_buffer))
879 pclass->release_buffer (pool, buffer);
881 dec_outstanding (pool);
883 /* decrease the refcount that the buffer had to us */
884 gst_object_unref (pool);