bufferpool: use same alignment values as GstMemory
[platform/upstream/gstreamer.git] / gst / gstbufferpool.c
1 /* GStreamer
2  * Copyright (C) 2010 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * gstbufferpool.c: GstBufferPool baseclass
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 /**
23  * SECTION:gstbufferpool
24  * @short_description: Pool for buffers
25  * @see_also: #GstBuffer
26  *
27  */
28
29 #include "gst_private.h"
30
31 #include <errno.h>
32 #ifdef HAVE_UNISTD_H
33 #  include <unistd.h>
34 #endif
35 #include <sys/types.h>
36
37 #include "gstinfo.h"
38 #include "gstquark.h"
39
40 #include "gstbufferpool.h"
41
42 GST_DEBUG_CATEGORY_STATIC (gst_buffer_pool_debug);
43 #define GST_CAT_DEFAULT gst_buffer_pool_debug
44
45 #define GST_BUFFER_POOL_GET_PRIVATE(obj)  \
46    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolPrivate))
47
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))
50
51 struct _GstBufferPoolPrivate
52 {
53   GStaticRecMutex rec_lock;
54   guint size;
55   guint min_buffers;
56   guint max_buffers;
57   guint prefix;
58   guint postfix;
59   guint align;
60 };
61
62 enum
63 {
64   /* add more above */
65   LAST_SIGNAL
66 };
67
68 static void gst_buffer_pool_finalize (GObject * object);
69
70 G_DEFINE_TYPE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
71
72 static gboolean default_start (GstBufferPool * pool);
73 static gboolean default_stop (GstBufferPool * pool);
74 static gboolean default_set_config (GstBufferPool * pool,
75     GstStructure * config);
76 static GstFlowReturn default_alloc_buffer (GstBufferPool * pool,
77     GstBuffer ** buffer, GstBufferPoolParams * params);
78 static GstFlowReturn default_acquire_buffer (GstBufferPool * pool,
79     GstBuffer ** buffer, GstBufferPoolParams * params);
80 static void default_free_buffer (GstBufferPool * pool, GstBuffer * buffer);
81 static void default_release_buffer (GstBufferPool * pool, GstBuffer * buffer);
82
83 static void
84 gst_buffer_pool_class_init (GstBufferPoolClass * klass)
85 {
86   GObjectClass *gobject_class = (GObjectClass *) klass;
87
88   g_type_class_add_private (klass, sizeof (GstBufferPoolPrivate));
89
90   gobject_class->finalize = gst_buffer_pool_finalize;
91
92   klass->start = default_start;
93   klass->stop = default_stop;
94   klass->set_config = default_set_config;
95   klass->acquire_buffer = default_acquire_buffer;
96   klass->alloc_buffer = default_alloc_buffer;
97   klass->release_buffer = default_release_buffer;
98   klass->free_buffer = default_free_buffer;
99
100   GST_DEBUG_CATEGORY_INIT (gst_buffer_pool_debug, "bufferpool", 0,
101       "bufferpool debug");
102 }
103
104 static void
105 gst_buffer_pool_init (GstBufferPool * pool)
106 {
107   pool->priv = GST_BUFFER_POOL_GET_PRIVATE (pool);
108
109   g_static_rec_mutex_init (&pool->priv->rec_lock);
110
111   pool->poll = gst_poll_new_timer ();
112   pool->queue = gst_atomic_queue_new (10);
113   pool->flushing = TRUE;
114   pool->active = FALSE;
115   pool->configured = FALSE;
116   pool->started = FALSE;
117   pool->config = gst_structure_id_empty_new (GST_QUARK (BUFFER_POOL_CONFIG));
118   gst_buffer_pool_config_set (pool->config, NULL, 0, 0, 0, 0, 0, 1);
119
120   GST_DEBUG_OBJECT (pool, "created");
121 }
122
123 static void
124 gst_buffer_pool_finalize (GObject * object)
125 {
126   GstBufferPool *pool;
127
128   pool = GST_BUFFER_POOL_CAST (object);
129
130   GST_DEBUG_OBJECT (pool, "finalize");
131
132   gst_buffer_pool_set_active (pool, FALSE);
133   gst_atomic_queue_unref (pool->queue);
134   gst_poll_free (pool->poll);
135   gst_structure_free (pool->config);
136   g_static_rec_mutex_free (&pool->priv->rec_lock);
137
138   G_OBJECT_CLASS (gst_buffer_pool_parent_class)->finalize (object);
139 }
140
141 /**
142  * gst_buffer_pool_new:
143  *
144  * Creates a new #GstBufferPool instance.
145  *
146  * Returns: a new #GstBufferPool instance
147  */
148 GstBufferPool *
149 gst_buffer_pool_new (void)
150 {
151   GstBufferPool *result;
152
153   result = g_object_newv (GST_TYPE_BUFFER_POOL, 0, NULL);
154   GST_DEBUG_OBJECT (result, "created new buffer pool");
155
156   return result;
157 }
158
159 static GstFlowReturn
160 default_alloc_buffer (GstBufferPool * pool, GstBuffer ** buffer,
161     GstBufferPoolParams * params)
162 {
163   GstBufferPoolPrivate *priv = pool->priv;
164
165   *buffer = gst_buffer_new ();
166
167   gst_buffer_take_memory (*buffer, gst_memory_allocator_alloc (NULL, priv->size,
168           priv->align));
169
170   return GST_FLOW_OK;
171 }
172
173 /* the default implementation for preallocating the buffers
174  * in the pool */
175 static gboolean
176 default_start (GstBufferPool * pool)
177 {
178   guint i;
179   GstBufferPoolPrivate *priv = pool->priv;
180   GstBufferPoolClass *pclass;
181
182   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
183
184   /* no alloc function, error */
185   if (G_UNLIKELY (pclass->alloc_buffer == NULL))
186     goto no_alloc;
187
188   /* we need to prealloc buffers */
189   for (i = 0; i < priv->min_buffers; i++) {
190     GstBuffer *buffer;
191
192     if (pclass->alloc_buffer (pool, &buffer, NULL) != GST_FLOW_OK)
193       goto alloc_failed;
194
195     GST_LOG_OBJECT (pool, "prealloced buffer %d: %p", i, buffer);
196     /* store in the queue */
197     gst_atomic_queue_push (pool->queue, buffer);
198     gst_poll_write_control (pool->poll);
199   }
200   return TRUE;
201
202   /* ERRORS */
203 no_alloc:
204   {
205     GST_WARNING_OBJECT (pool, "no alloc function");
206     return FALSE;
207   }
208 alloc_failed:
209   {
210     GST_WARNING_OBJECT (pool, "alloc function failed");
211     return FALSE;
212   }
213 }
214
215 /* must be called with the lock */
216 static gboolean
217 do_start (GstBufferPool * pool)
218 {
219   if (!pool->started) {
220     GstBufferPoolClass *pclass;
221
222     pclass = GST_BUFFER_POOL_GET_CLASS (pool);
223
224     GST_LOG_OBJECT (pool, "starting");
225     /* start the pool, subclasses should allocate buffers and put them
226      * in the queue */
227     if (G_LIKELY (pclass->start)) {
228       if (!pclass->start (pool))
229         return FALSE;
230     }
231     pool->started = TRUE;
232   }
233   return TRUE;
234 }
235
236
237 static void
238 default_free_buffer (GstBufferPool * pool, GstBuffer * buffer)
239 {
240   gst_buffer_unref (buffer);
241 }
242
243 /* must be called with the lock */
244 static gboolean
245 default_stop (GstBufferPool * pool)
246 {
247   GstBuffer *buffer;
248   GstBufferPoolClass *pclass;
249
250   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
251
252   /* clear the pool */
253   while ((buffer = gst_atomic_queue_pop (pool->queue))) {
254     gst_poll_read_control (pool->poll);
255
256     if (G_LIKELY (pclass->free_buffer))
257       pclass->free_buffer (pool, buffer);
258   }
259   return TRUE;
260 }
261
262 /* must be called with the lock */
263 static gboolean
264 do_stop (GstBufferPool * pool)
265 {
266   if (pool->started) {
267     GstBufferPoolClass *pclass;
268
269     pclass = GST_BUFFER_POOL_GET_CLASS (pool);
270
271     GST_LOG_OBJECT (pool, "stopping");
272     if (G_LIKELY (pclass->stop)) {
273       if (!pclass->stop (pool))
274         return FALSE;
275     }
276     pool->started = FALSE;
277   }
278   return TRUE;
279 }
280
281 /**
282  * gst_buffer_pool_set_active:
283  * @pool: a #GstBufferPool
284  * @active: the new active state
285  *
286  * Control the active state of @pool. When the pool is active, new calls to
287  * gst_buffer_pool_acquire_buffer() will return with GST_FLOW_WRONG_STATE.
288  *
289  * Returns: %FALSE when the pool was not configured or when preallocation of the
290  * buffers failed.
291  */
292 gboolean
293 gst_buffer_pool_set_active (GstBufferPool * pool, gboolean active)
294 {
295   gboolean res = TRUE;
296
297   g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
298
299   GST_LOG_OBJECT (pool, "active %d", active);
300
301   GST_BUFFER_POOL_LOCK (pool);
302   /* just return if we are already in the right state */
303   if (pool->active == active)
304     goto was_ok;
305
306   /* we need to be configured */
307   if (!pool->configured)
308     goto not_configured;
309
310   if (active) {
311     if (!do_start (pool))
312       goto start_failed;
313
314     /* unset the flushing state now */
315     gst_poll_read_control (pool->poll);
316     g_atomic_int_set (&pool->flushing, FALSE);
317   } else {
318     /* set to flushing first */
319     g_atomic_int_set (&pool->flushing, TRUE);
320     gst_poll_write_control (pool->poll);
321
322     /* when all buffers are in the pool, free them. Else they will be
323      * freed when they are released */
324     if (g_atomic_int_get (&pool->outstanding) == 0) {
325       if (!do_stop (pool))
326         goto stop_failed;
327     }
328   }
329   pool->active = active;
330   GST_BUFFER_POOL_UNLOCK (pool);
331
332   return res;
333
334 was_ok:
335   {
336     GST_DEBUG_OBJECT (pool, "pool was in the right state");
337     GST_BUFFER_POOL_UNLOCK (pool);
338     return TRUE;
339   }
340 not_configured:
341   {
342     GST_ERROR_OBJECT (pool, "pool was not configured");
343     GST_BUFFER_POOL_UNLOCK (pool);
344     return FALSE;
345   }
346 start_failed:
347   {
348     GST_ERROR_OBJECT (pool, "start failed");
349     GST_BUFFER_POOL_UNLOCK (pool);
350     return FALSE;
351   }
352 stop_failed:
353   {
354     GST_WARNING_OBJECT (pool, "stop failed");
355     GST_BUFFER_POOL_UNLOCK (pool);
356     return FALSE;
357   }
358 }
359
360 static gboolean
361 default_set_config (GstBufferPool * pool, GstStructure * config)
362 {
363   GstBufferPoolPrivate *priv = pool->priv;
364   const GstCaps *caps;
365   guint size, min_buffers, max_buffers;
366   guint prefix, postfix, align;
367
368   /* parse the config and keep around */
369   if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers,
370           &max_buffers, &prefix, &postfix, &align))
371     goto wrong_config;
372
373   GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config);
374
375   priv->size = size;
376   priv->min_buffers = min_buffers;
377   priv->max_buffers = max_buffers;
378   priv->prefix = prefix;
379   priv->postfix = postfix;
380   priv->align = align;
381
382   return TRUE;
383
384 wrong_config:
385   {
386     GST_WARNING_OBJECT (pool, "invalid config %" GST_PTR_FORMAT, config);
387     return FALSE;
388   }
389 }
390
391 /**
392  * gst_buffer_pool_set_config:
393  * @pool: a #GstBufferPool
394  * @config: a #GstStructure
395  *
396  * Set the configuration of the pool. The pool must be inactive and all buffers
397  * allocated form this pool must be returned or else this function will do
398  * nothing and return FALSE.
399  *
400  * @condfig is a #GstStructure that contains the configuration parameters for
401  * the pool. A default and mandatory set of parameters can be configured with
402  * gst_buffer_pool_config_set(). This function takes ownership of @config.
403  *
404  * Returns: TRUE when the configuration could be set.
405  */
406 gboolean
407 gst_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
408 {
409   gboolean result;
410   GstBufferPoolClass *pclass;
411
412   g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
413   g_return_val_if_fail (config != NULL, FALSE);
414
415   GST_BUFFER_POOL_LOCK (pool);
416   /* can't change the settings when active */
417   if (pool->active)
418     goto was_active;
419
420   /* we can't change when outstanding buffers */
421   if (g_atomic_int_get (&pool->outstanding) != 0)
422     goto have_outstanding;
423
424   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
425
426   /* set the new config */
427   if (G_LIKELY (pclass->set_config))
428     result = pclass->set_config (pool, config);
429   else
430     result = FALSE;
431
432   if (result) {
433     if (pool->config)
434       gst_structure_free (pool->config);
435     pool->config = config;
436
437     /* now we are configured */
438     pool->configured = TRUE;
439   }
440   GST_BUFFER_POOL_UNLOCK (pool);
441
442   return result;
443
444   /* ERRORS */
445 was_active:
446   {
447     GST_WARNING_OBJECT (pool, "can't change config, we are active");
448     GST_BUFFER_POOL_UNLOCK (pool);
449     return FALSE;
450   }
451 have_outstanding:
452   {
453     GST_WARNING_OBJECT (pool, "can't change config, have outstanding buffers");
454     GST_BUFFER_POOL_UNLOCK (pool);
455     return FALSE;
456   }
457 }
458
459 /**
460  * gst_buffer_pool_get_config:
461  * @pool: a #GstBufferPool
462  *
463  * Get a copy of the current configuration of the pool. This configuration
464  * can either be modified and used for the gst_buffer_pool_set_config() call
465  * or it must be freed after usage.
466  *
467  * Returns: a copy of the current configuration of @pool. use
468  * gst_structure_free() after usage or gst_buffer_pool_set_config().
469  */
470 GstStructure *
471 gst_buffer_pool_get_config (GstBufferPool * pool)
472 {
473   GstStructure *result;
474
475   g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), NULL);
476
477   GST_BUFFER_POOL_UNLOCK (pool);
478   result = gst_structure_copy (pool->config);
479   GST_BUFFER_POOL_UNLOCK (pool);
480
481   return result;
482 }
483
484 /**
485  * gst_buffer_pool_config_set:
486  * @config: a #GstBufferPool
487  * @caps: caps for the buffers
488  * @size: the size of each buffer, not including pre and post fix
489  * @min_buffers: the minimum amount of buffers to allocate.
490  * @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
491  * @prefix: prefix each buffer with this many bytes
492  * @postfix: postfix each buffer with this many bytes
493  * @align: alignment of the buffer data.
494  *
495  * Configure @config with the given parameters.
496  */
497 void
498 gst_buffer_pool_config_set (GstStructure * config, const GstCaps * caps,
499     guint size, guint min_buffers, guint max_buffers, guint prefix,
500     guint postfix, guint align)
501 {
502   g_return_if_fail (config != NULL);
503
504   gst_structure_id_set (config,
505       GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
506       GST_QUARK (SIZE), G_TYPE_UINT, size,
507       GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
508       GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
509       GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
510       GST_QUARK (POSTFIX), G_TYPE_UINT, postfix,
511       GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
512 }
513
514 /**
515  * gst_buffer_pool_config_get:
516  * @config: a #GstBufferPool
517  * @caps: the caps of buffers
518  * @size: the size of each buffer, not including pre and post fix
519  * @min_buffers: the minimum amount of buffers to allocate.
520  * @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
521  * @prefix: prefix each buffer with this many bytes
522  * @postfix: postfix each buffer with this many bytes
523  * @align: alignment of the buffer data.
524  *
525  * Get the configuration values from @config.
526  */
527 gboolean
528 gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps,
529     guint * size, guint * min_buffers, guint * max_buffers, guint * prefix,
530     guint * postfix, guint * align)
531 {
532   g_return_val_if_fail (config != NULL, FALSE);
533
534   return gst_structure_id_get (config,
535       GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
536       GST_QUARK (SIZE), G_TYPE_UINT, size,
537       GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
538       GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
539       GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
540       GST_QUARK (POSTFIX), G_TYPE_UINT, postfix,
541       GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
542 }
543
544 static GstFlowReturn
545 default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
546     GstBufferPoolParams * params)
547 {
548   GstFlowReturn result;
549   GstBufferPoolClass *pclass;
550   GstBufferPoolPrivate *priv = pool->priv;
551
552   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
553
554   while (TRUE) {
555     if (G_UNLIKELY (g_atomic_int_get (&pool->flushing)))
556       goto flushing;
557
558     /* try to get a buffer from the queue */
559     *buffer = gst_atomic_queue_pop (pool->queue);
560     if (G_LIKELY (*buffer)) {
561       gst_poll_read_control (pool->poll);
562       result = GST_FLOW_OK;
563       GST_LOG_OBJECT (pool, "acquired buffer %p", *buffer);
564       break;
565     }
566
567     /* no buffer */
568     if (priv->max_buffers == 0) {
569       /* no max_buffers, we allocate some more */
570       if (G_LIKELY (pclass->alloc_buffer)) {
571         result = pclass->alloc_buffer (pool, buffer, params);
572       } else
573         result = GST_FLOW_NOT_SUPPORTED;
574       GST_LOG_OBJECT (pool, "alloc buffer %p", *buffer);
575       break;
576     }
577
578     /* check if we need to wait */
579     if (params && (params->flags & GST_BUFFER_POOL_FLAG_DONTWAIT)) {
580       GST_LOG_OBJECT (pool, "no more buffers");
581       result = GST_FLOW_UNEXPECTED;
582       break;
583     }
584
585     /* now wait */
586     GST_LOG_OBJECT (pool, "waiting for free buffers");
587     gst_poll_wait (pool->poll, GST_CLOCK_TIME_NONE);
588   }
589
590   return result;
591
592   /* ERRORS */
593 flushing:
594   {
595     GST_DEBUG_OBJECT (pool, "we are flushing");
596     return GST_FLOW_WRONG_STATE;
597   }
598 }
599
600 static inline void
601 dec_outstanding (GstBufferPool * pool)
602 {
603   if (g_atomic_int_dec_and_test (&pool->outstanding)) {
604     /* all buffers are returned to the pool, see if we need to free them */
605     if (g_atomic_int_get (&pool->flushing)) {
606       /* take the lock so that set_active is not run concurrently */
607       GST_BUFFER_POOL_LOCK (pool);
608       /* recheck the flushing state in the lock, the pool could have been
609        * set to active again */
610       if (g_atomic_int_get (&pool->flushing))
611         do_stop (pool);
612
613       GST_BUFFER_POOL_UNLOCK (pool);
614     }
615   }
616 }
617
618 /**
619  * gst_buffer_pool_acquire_buffer:
620  * @pool: a #GstBufferPool
621  * @buffer: a location for a #GstBuffer
622  * @params: parameters.
623  *
624  * Acquire a buffer from @pool. @buffer should point to a memory location that
625  * can hold a pointer to the new buffer.
626  *
627  * @params can be NULL or contain optional parameters to influence the allocation.
628  *
629  * Returns: a #GstFlowReturn such as GST_FLOW_WRONG_STATE when the pool is
630  * inactive.
631  */
632 GstFlowReturn
633 gst_buffer_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
634     GstBufferPoolParams * params)
635 {
636   GstBufferPoolClass *pclass;
637   GstFlowReturn result;
638
639   g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), GST_FLOW_ERROR);
640   g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
641
642   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
643
644   /* assume we'll have one more outstanding buffer we need to do that so
645    * that concurrent set_active doesn't clear the buffers */
646   g_atomic_int_inc (&pool->outstanding);
647
648   if (G_LIKELY (pclass->acquire_buffer))
649     result = pclass->acquire_buffer (pool, buffer, params);
650   else
651     result = GST_FLOW_NOT_SUPPORTED;
652
653   if (G_LIKELY (result == GST_FLOW_OK)) {
654     /* all buffers from the pool point to the pool and have the refcount of the
655      * pool incremented */
656     (*buffer)->pool = gst_object_ref (pool);
657   } else {
658     dec_outstanding (pool);
659   }
660
661   return result;
662 }
663
664 static void
665 default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
666 {
667   /* keep it around in our queue */
668   GST_LOG_OBJECT (pool, "released buffer %p", buffer);
669   gst_atomic_queue_push (pool->queue, buffer);
670   gst_poll_write_control (pool->poll);
671 }
672
673 /**
674  * gst_buffer_pool_release_buffer:
675  * @pool: a #GstBufferPool
676  * @buffer: a #GstBuffer
677  *
678  * Release @buffer to @pool. @buffer should have previously been allocated from
679  * @pool with gst_buffer_pool_acquire_buffer().
680  *
681  * This function is usually called automatically when the last ref on @buffer
682  * disappears.
683  */
684 void
685 gst_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
686 {
687   GstBufferPoolClass *pclass;
688
689   g_return_if_fail (GST_IS_BUFFER_POOL (pool));
690   g_return_if_fail (buffer != NULL);
691
692   /* check that the buffer is ours, all buffers returned to the pool have the
693    * pool member set to NULL and the pool refcount decreased */
694   if (!g_atomic_pointer_compare_and_exchange ((gpointer *) & buffer->pool,
695           pool, NULL))
696     return;
697
698   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
699
700   if (G_LIKELY (pclass->release_buffer))
701     pclass->release_buffer (pool, buffer);
702
703   dec_outstanding (pool);
704
705   /* decrease the refcount that the buffer had to us */
706   gst_object_unref (pool);
707 }