Commit 4e45e0a2 authored by René Stadler's avatar René Stadler Committed by Tim-Philipp Müller

Add replaygain playback elements (#412710).

Original commit message from CVS:
Patch by: René Stadler <mail at renestadler de>
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-bad-plugins-docs.sgml:
* docs/plugins/gst-plugins-bad-plugins-sections.txt:
* docs/plugins/inspect/plugin-replaygain.xml:
* gst/replaygain/Makefile.am:
* gst/replaygain/gstrganalysis.c: (gst_rg_analysis_class_init),
(gst_rg_analysis_start), (gst_rg_analysis_set_caps),
(gst_rg_analysis_transform_ip), (gst_rg_analysis_event),
(gst_rg_analysis_stop), (gst_rg_analysis_handle_tags),
(gst_rg_analysis_handle_eos), (gst_rg_analysis_track_result),
(gst_rg_analysis_album_result):
* gst/replaygain/gstrganalysis.h:
* gst/replaygain/gstrglimiter.c: (gst_rg_limiter_base_init),
(gst_rg_limiter_class_init), (gst_rg_limiter_init),
(gst_rg_limiter_set_property), (gst_rg_limiter_get_property),
(gst_rg_limiter_transform_ip):
* gst/replaygain/gstrglimiter.h:
* gst/replaygain/gstrgvolume.c: (gst_rg_volume_base_init),
(gst_rg_volume_class_init), (gst_rg_volume_init),
(gst_rg_volume_set_property), (gst_rg_volume_get_property),
(gst_rg_volume_dispose), (gst_rg_volume_change_state),
(gst_rg_volume_sink_event), (gst_rg_volume_tag_event),
(gst_rg_volume_reset), (gst_rg_volume_update_gain),
(gst_rg_volume_determine_gain):
* gst/replaygain/gstrgvolume.h:
* gst/replaygain/replaygain.c: (plugin_init):
* gst/replaygain/replaygain.h:
* gst/replaygain/rganalysis.h:
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/rganalysis.c: (send_eos_event),
(GST_START_TEST):
* tests/check/elements/rglimiter.c: (setup_rglimiter),
(cleanup_rglimiter), (set_playing_state), (create_test_buffer),
(verify_test_buffer), (GST_START_TEST), (rglimiter_suite), (main):
* tests/check/elements/rgvolume.c: (event_func), (setup_rgvolume),
(cleanup_rgvolume), (set_playing_state), (set_null_state),
(send_eos_event), (send_tag_event), (test_buffer_new),
(fail_unless_target_gain), (fail_unless_result_gain),
(fail_unless_gain), (GST_START_TEST), (rgvolume_suite), (main):
Add replaygain playback elements (#412710).
parent fc99abef
......@@ -2,12 +2,20 @@ plugin_LTLIBRARIES = libgstreplaygain.la
libgstreplaygain_la_SOURCES = \
gstrganalysis.c \
gstrglimiter.c \
gstrgvolume.c \
replaygain.c \
rganalysis.c
libgstreplaygain_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS)
libgstreplaygain_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(LIBM)
libgstreplaygain_la_CFLAGS = \
$(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstreplaygain_la_LIBADD = \
$(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-0.10 $(LIBM)
libgstreplaygain_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
# headers we need but don't want installed
noinst_HEADERS = \
gstrganalysis.h \
gstrglimiter.h \
gstrgvolume.h \
replaygain.h \
rganalysis.h
This diff is collapsed.
......@@ -78,6 +78,8 @@ struct _GstRgAnalysisClass
GstBaseTransformClass parent_class;
};
GType gst_rg_analysis_get_type (void);
G_END_DECLS
#endif /* __GST_RG_ANALYSIS_H__ */
/* GStreamer ReplayGain limiter
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
*
* gstrglimiter.c: Element to apply signal compression to raw audio data
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/**
* SECTION:element-rglimiter
* @see_also: <link linkend="GstRgVolume">rgvolume</link>
*
* <refsect2>
* <para>
* This element applies signal compression/limiting to raw audio data. It
* performs strict hard limiting with soft-knee characteristics, using a
* threshold of -6 dB. This type of filter is mentioned in the proposed <ulink
* url="http://replaygain.org">ReplayGain standard</ulink>.
* </para>
* <title>Example launch line</title>
* <para>Playback of a file:</para>
* <programlisting>
* gst-launch filesrc location="Filename.ext" ! decodebin ! audioconvert \
* ! rgvolume pre-amp=6.0 headroom=10.0 ! rglimiter \
* ! audioconvert ! audioresample ! alsasink
* </programlisting>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gst/gst.h>
#include <math.h>
#include "gstrglimiter.h"
GST_DEBUG_CATEGORY_STATIC (gst_rg_limiter_debug);
#define GST_CAT_DEFAULT gst_rg_limiter_debug
enum
{
PROP_0,
PROP_ENABLED,
};
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, channels = (int) [1, MAX], "
"rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
"width = (int) 32, channels = (int) [1, MAX], "
"rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
GST_BOILERPLATE (GstRgLimiter, gst_rg_limiter, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM);
static void gst_rg_limiter_class_init (GstRgLimiterClass * klass);
static void gst_rg_limiter_init (GstRgLimiter * filter,
GstRgLimiterClass * gclass);
static void gst_rg_limiter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_rg_limiter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstFlowReturn gst_rg_limiter_transform_ip (GstBaseTransform * base,
GstBuffer * buf);
static const GstElementDetails element_details = {
"ReplayGain limiter",
"Filter/Effect/Audio",
"Apply signal compression to raw audio data",
"Ren\xc3\xa9 Stadler <mail@renestadler.de>"
};
static void
gst_rg_limiter_base_init (gpointer g_class)
{
GstElementClass *element_class = g_class;
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &element_details);
GST_DEBUG_CATEGORY_INIT (gst_rg_limiter_debug, "rglimiter", 0,
"ReplayGain limiter element");
}
static void
gst_rg_limiter_class_init (GstRgLimiterClass * klass)
{
GObjectClass *gobject_class;
GstBaseTransformClass *trans_class;
gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_rg_limiter_set_property;
gobject_class->get_property = gst_rg_limiter_get_property;
g_object_class_install_property (gobject_class, PROP_ENABLED,
g_param_spec_boolean ("enabled", "Enabled", "Enable processing", TRUE,
G_PARAM_READWRITE));
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rg_limiter_transform_ip);
trans_class->passthrough_on_same_caps = FALSE;
}
static void
gst_rg_limiter_init (GstRgLimiter * filter, GstRgLimiterClass * gclass)
{
filter->enabled = TRUE;
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE);
}
static void
gst_rg_limiter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstRgLimiter *filter = GST_RG_LIMITER (object);
switch (prop_id) {
case PROP_ENABLED:
filter->enabled = g_value_get_boolean (value);
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter),
!filter->enabled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_rg_limiter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstRgLimiter *filter = GST_RG_LIMITER (object);
switch (prop_id) {
case PROP_ENABLED:
g_value_set_boolean (value, filter->enabled);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
#define LIMIT 1.0
#define THRES 0.5 /* ca. -6 dB */
#define COMPL 0.5 /* LIMIT - THRESH */
static GstFlowReturn
gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
{
GstRgLimiter *filter = GST_RG_LIMITER (base);
gfloat *input;
guint count;
guint i;
if (!filter->enabled)
return GST_FLOW_OK;
input = (gfloat *) GST_BUFFER_DATA (buf);
count = GST_BUFFER_SIZE (buf) / sizeof (gfloat);
for (i = count; i--;) {
if (*input > THRES)
*input = tanhf ((*input - THRES) / COMPL) * COMPL + THRES;
else if (*input < -THRES)
*input = tanhf ((*input + THRES) / COMPL) * COMPL - THRES;
input++;
}
return GST_FLOW_OK;
}
/* GStreamer ReplayGain limiter
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
*
* gstrglimiter.h: Element to apply signal compression to raw audio data
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __GST_RG_LIMITER_H__
#define __GST_RG_LIMITER_H__
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#define GST_TYPE_RG_LIMITER \
(gst_rg_limiter_get_type())
#define GST_RG_LIMITER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RG_LIMITER,GstRgLimiter))
#define GST_RG_LIMITER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RG_LIMITER,GstRgLimiterClass))
#define GST_IS_RG_LIMITER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RG_LIMITER))
#define GST_IS_RG_LIMITER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RG_LIMITER))
typedef struct _GstRgLimiter GstRgLimiter;
typedef struct _GstRgLimiterClass GstRgLimiterClass;
/**
* GstRgLimiter:
*
* Opaque data structure.
*/
struct _GstRgLimiter
{
GstBaseTransform element;
/*< private >*/
gboolean enabled;
};
struct _GstRgLimiterClass
{
GstBaseTransformClass parent_class;
};
GType gst_rg_limiter_get_type (void);
#endif /* __GST_RG_LIMITER_H__ */
This diff is collapsed.
/* GStreamer ReplayGain volume adjustment
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
*
* gstrgvolume.h: Element to apply ReplayGain volume adjustment
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __GST_RG_VOLUME_H__
#define __GST_RG_VOLUME_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_RG_VOLUME \
(gst_rg_volume_get_type())
#define GST_RG_VOLUME(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RG_VOLUME,GstRgVolume))
#define GST_RG_VOLUME_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RG_VOLUME,GstRgVolumeClass))
#define GST_IS_PLUGIN_TEMPLATE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RG_VOLUME))
#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RG_VOLUME))
typedef struct _GstRgVolume GstRgVolume;
typedef struct _GstRgVolumeClass GstRgVolumeClass;
/**
* GstRgVolume:
*
* Opaque data structure.
*/
struct _GstRgVolume
{
GstBin bin;
/*< private >*/
GstElement *volume_element;
gdouble max_volume;
gboolean album_mode;
gdouble headroom;
gdouble pre_amp;
gdouble fallback_gain;
gdouble target_gain;
gdouble result_gain;
gdouble track_gain;
gdouble track_peak;
gdouble album_gain;
gdouble album_peak;
gboolean has_track_gain;
gboolean has_track_peak;
gboolean has_album_gain;
gboolean has_album_peak;
gdouble reference_level;
};
struct _GstRgVolumeClass
{
GstBinClass parent_class;
};
GType gst_rg_volume_get_type (void);
G_END_DECLS
#endif /* __GST_RG_VOLUME_H__ */
/* GStreamer ReplayGain plugin
*
* Copyright (C) 2006 Rene Stadler <mail@renestadler.de>
*
* replaygain.c: Plugin providing ReplayGain related elements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gst/gst.h>
#include "gstrganalysis.h"
#include "gstrglimiter.h"
#include "gstrgvolume.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "rganalysis", GST_RANK_NONE,
GST_TYPE_RG_ANALYSIS))
return FALSE;
if (!gst_element_register (plugin, "rglimiter", GST_RANK_NONE,
GST_TYPE_RG_LIMITER))
return FALSE;
if (!gst_element_register (plugin, "rgvolume", GST_RANK_NONE,
GST_TYPE_RG_VOLUME))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "replaygain",
"ReplayGain volume normalization", plugin_init, VERSION, GST_LICENSE,
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
/* GStreamer ReplayGain plugin
*
* Copyright (C) 2006 Rene Stadler <mail@renestadler.de>
*
* replaygain.h: Plugin providing ReplayGain related elements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __REPLAYGAIN_H__
#define __REPLAYGAIN_H__
G_BEGIN_DECLS
/* Reference level (in dBSPL). The 2001 proposal specifies 83. This was
* changed later in all implementations to 89, which is the new, offical value:
* David Robinson acknowledged the change but didn't update the website yet. */
#define RG_REFERENCE_LEVEL 89.
G_END_DECLS
#endif /* __REPLAYGAIN_H__ */
......@@ -29,8 +29,6 @@
G_BEGIN_DECLS
#define RG_REFERENCE_LEVEL 89.
typedef struct _RgAnalysisCtx RgAnalysisCtx;
RgAnalysisCtx *rg_analysis_new (void);
......
This diff is collapsed.
/* GStreamer ReplayGain limiter
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
*
* rglimiter.c: Unit test for the rglimiter element
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <gst/check/gstcheck.h>
#include <math.h>
GList *buffers = NULL;
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
static GstPad *mysrcpad, *mysinkpad;
#define RG_LIMITER_CAPS_TEMPLATE_STRING \
"audio/x-raw-float, " \
"width = (int) 32, " \
"endianness = (int) BYTE_ORDER, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ]"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RG_LIMITER_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RG_LIMITER_CAPS_TEMPLATE_STRING)
);
GstElement *
setup_rglimiter ()
{
GstElement *element;
GstBus *bus;
GST_DEBUG ("setup_rglimiter");
element = gst_check_setup_element ("rglimiter");
mysrcpad = gst_check_setup_src_pad (element, &srctemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate, NULL);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
return element;
}
void
cleanup_rglimiter (GstElement * element)
{
GST_DEBUG ("cleanup_rglimiter");
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
gst_check_teardown_src_pad (element);
gst_check_teardown_sink_pad (element);
gst_check_teardown_element (element);
}
static void
set_playing_state (GstElement * element)
{
fail_unless (gst_element_set_state (element,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"Could not set state to PLAYING");
}
static const gfloat test_input[] = {
-2.0, -1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, 2.0
};
static const gfloat test_output[] = {
-0.99752737684336523, /* -2.0 */
-0.88079707797788243, /* -1.0 */
-0.7310585786300049, /* -0.75 */
-0.5, -0.25, 0.0, 0.25, 0.5,
0.7310585786300049, /* 0.75 */
0.88079707797788243, /* 1.0 */
0.99752737684336523, /* 2.0 */
};
static GstBuffer *
create_test_buffer ()
{
GstBuffer *buf = gst_buffer_new_and_alloc (sizeof (test_input));
GstCaps *caps;
memcpy (GST_BUFFER_DATA (buf), test_input, sizeof (test_input));
caps = gst_caps_new_simple ("audio/x-raw-float",
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1,
"endianess", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL);
gst_buffer_set_caps (buf, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (buf, "buf", 1);
return buf;
}
static void
verify_test_buffer (GstBuffer * buf)
{
gfloat *output = (gfloat *) GST_BUFFER_DATA (buf);
gint i;
fail_unless (GST_BUFFER_SIZE (buf) == sizeof (test_output));
for (i = 0; i < G_N_ELEMENTS (test_input); i++)
fail_unless (ABS (output[i] - test_output[i]) < 1.e-6,
"Incorrect output value %.6f for input %.2f, expected %.6f",
output[i], test_input[i], test_output[i]);
}
/* Start of tests. */
GST_START_TEST (test_no_buffer)
{
GstElement *element = setup_rglimiter ();
set_playing_state (element);
cleanup_rglimiter (element);
}
GST_END_TEST;
GST_START_TEST (test_disabled)
{
GstElement *element = setup_rglimiter ();
GstBuffer *buf, *out_buf;
g_object_set (element, "enabled", FALSE, NULL);
set_playing_state (element);
buf = create_test_buffer ();
fail_unless (gst_pad_push (mysrcpad, buf) == GST_FLOW_OK);
fail_unless (g_list_length (buffers) == 1);
out_buf = buffers->data;
fail_if (out_buf == NULL);
buffers = g_list_remove (buffers, out_buf);