Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / tests / check / elements / rgvolume.c
1 /* GStreamer ReplayGain volume adjustment
2  *
3  * Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
4  *
5  * rgvolume.c: Unit test for the rgvolume element
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  * 
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  * 
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  */
22
23 #include <gst/check/gstcheck.h>
24 #include <gst/audio/audio.h>
25
26 #include <math.h>
27
28 GList *events = NULL;
29
30 /* For ease of programming we use globals to keep refs for our floating src and
31  * sink pads we create; otherwise we always have to do get_pad, get_peer, and
32  * then remove references in every test function */
33 static GstPad *mysrcpad, *mysinkpad;
34
35 #define RG_VOLUME_CAPS_TEMPLATE_STRING        \
36   "audio/x-raw, "                             \
37   "format = (string) "GST_AUDIO_NE (F32) ", " \
38   "channels = (int) [ 1, MAX ], "             \
39   "rate = (int) [ 1, MAX ]"
40
41 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
42     GST_PAD_SINK,
43     GST_PAD_ALWAYS,
44     GST_STATIC_CAPS (RG_VOLUME_CAPS_TEMPLATE_STRING)
45     );
46 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
47     GST_PAD_SRC,
48     GST_PAD_ALWAYS,
49     GST_STATIC_CAPS (RG_VOLUME_CAPS_TEMPLATE_STRING)
50     );
51
52 static GstBuffer *test_buffer_new (gfloat value);
53
54 /* gstcheck sets up a chain function that appends buffers to a global list.
55  * This is our equivalent of that for event handling. */
56 static gboolean
57 event_func (GstPad * pad, GstObject * parent, GstEvent * event)
58 {
59   events = g_list_append (events, event);
60
61   return TRUE;
62 }
63
64 static GstElement *
65 setup_rgvolume (void)
66 {
67   GstElement *element;
68
69   GST_DEBUG ("setup_rgvolume");
70   element = gst_check_setup_element ("rgvolume");
71   mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
72   mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);
73
74   /* Capture events, to test tag filtering behavior: */
75   gst_pad_set_event_function (mysinkpad, event_func);
76
77   gst_pad_set_active (mysrcpad, TRUE);
78   gst_pad_set_active (mysinkpad, TRUE);
79
80   return element;
81 }
82
83 static void
84 send_newsegment_and_empty_buffer (void)
85 {
86   GstBuffer *buf;
87   GstEvent *ev;
88   GstSegment segment;
89
90   fail_unless (g_list_length (events) == 0);
91
92   gst_segment_init (&segment, GST_FORMAT_TIME);
93   ev = gst_event_new_segment (&segment);
94   fail_unless (gst_pad_push_event (mysrcpad, ev),
95       "Pushing newsegment event failed");
96
97   buf = test_buffer_new (0.0);
98   GST_BUFFER_SIZE (buf) = 0;
99   GST_BUFFER_DURATION (buf) = 0;
100   GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET (buf);
101   fail_unless (gst_pad_push (mysrcpad, buf) == GST_FLOW_OK);
102
103   fail_unless (g_list_length (events) == 1);
104   fail_unless (events->data == ev);
105   gst_mini_object_unref ((GstMiniObject *) events->data);
106   events = g_list_remove (events, ev);
107
108   fail_unless (g_list_length (buffers) == 1);
109   fail_unless (buffers->data == buf);
110   gst_mini_object_unref ((GstMiniObject *) buffers->data);
111   buffers = g_list_remove (buffers, buf);
112 }
113
114 static void
115 cleanup_rgvolume (GstElement * element)
116 {
117   GST_DEBUG ("cleanup_rgvolume");
118
119   g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
120   g_list_free (buffers);
121   buffers = NULL;
122
123   g_list_foreach (events, (GFunc) gst_mini_object_unref, NULL);
124   g_list_free (events);
125   events = NULL;
126
127   gst_pad_set_active (mysrcpad, FALSE);
128   gst_pad_set_active (mysinkpad, FALSE);
129   gst_check_teardown_src_pad (element);
130   gst_check_teardown_sink_pad (element);
131   gst_check_teardown_element (element);
132 }
133
134 static void
135 set_playing_state (GstElement * element)
136 {
137   fail_unless (gst_element_set_state (element,
138           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
139       "Could not set state to PLAYING");
140 }
141
142 static void
143 set_null_state (GstElement * element)
144 {
145   fail_unless (gst_element_set_state (element,
146           GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS,
147       "Could not set state to NULL");
148 }
149
150 static void
151 send_eos_event (GstElement * element)
152 {
153   GstEvent *event = gst_event_new_eos ();
154
155   fail_unless (g_list_length (events) == 0);
156   fail_unless (gst_pad_push_event (mysrcpad, event),
157       "Pushing EOS event failed");
158   fail_unless (g_list_length (events) == 1);
159   fail_unless (events->data == event);
160   gst_mini_object_unref ((GstMiniObject *) events->data);
161   events = g_list_remove (events, event);
162 }
163
164 static GstEvent *
165 send_tag_event (GstElement * element, GstEvent * event)
166 {
167   g_return_val_if_fail (event->type == GST_EVENT_TAG, NULL);
168
169   fail_unless (g_list_length (events) == 0);
170   fail_unless (gst_pad_push_event (mysrcpad, event),
171       "Pushing tag event failed");
172
173   if (g_list_length (events) == 0) {
174     /* Event got filtered out. */
175     event = NULL;
176   } else {
177     GstTagList *tag_list;
178     gdouble dummy;
179
180     event = events->data;
181     events = g_list_remove (events, event);
182
183     fail_unless (event->type == GST_EVENT_TAG);
184     gst_event_parse_tag (event, &tag_list);
185
186     /* The element is supposed to filter out ReplayGain related tags. */
187     fail_if (gst_tag_list_get_double (tag_list, GST_TAG_TRACK_GAIN, &dummy),
188         "tag event still contains track gain tag");
189     fail_if (gst_tag_list_get_double (tag_list, GST_TAG_TRACK_PEAK, &dummy),
190         "tag event still contains track peak tag");
191     fail_if (gst_tag_list_get_double (tag_list, GST_TAG_ALBUM_GAIN, &dummy),
192         "tag event still contains album gain tag");
193     fail_if (gst_tag_list_get_double (tag_list, GST_TAG_ALBUM_PEAK, &dummy),
194         "tag event still contains album peak tag");
195   }
196
197   return event;
198 }
199
200 static GstBuffer *
201 test_buffer_new (gfloat value)
202 {
203   GstBuffer *buf;
204   GstCaps *caps;
205   gfloat *data;
206   gint i;
207
208   buf = gst_buffer_new_and_alloc (8 * sizeof (gfloat));
209   data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
210   for (i = 0; i < 8; i++)
211     data[i] = value;
212   gst_buffer_unmap (buf, data, -1);
213
214   caps = gst_caps_from_string ("audio/x-raw-float, "
215       "rate = 8000, channels = 1, endianness = BYTE_ORDER, width = 32");
216   gst_pad_set_caps (mysrcpad, caps);
217   gst_caps_unref (caps);
218
219   ASSERT_BUFFER_REFCOUNT (buf, "buf", 1);
220
221   return buf;
222 }
223
224 #define MATCH_GAIN(g1, g2) ((g1 < g2 + 1e-6) && (g2 < g1 + 1e-6))
225
226 static void
227 fail_unless_target_gain (GstElement * element, gdouble expected_gain)
228 {
229   gdouble prop_gain;
230
231   g_object_get (element, "target-gain", &prop_gain, NULL);
232
233   fail_unless (MATCH_GAIN (prop_gain, expected_gain),
234       "Target gain is %.2f dB, expected %.2f dB", prop_gain, expected_gain);
235 }
236
237 static void
238 fail_unless_result_gain (GstElement * element, gdouble expected_gain)
239 {
240   GstBuffer *input_buf, *output_buf;
241   gfloat *data;
242   gfloat input_sample, output_sample;
243   gdouble gain, prop_gain;
244   gboolean is_passthrough, expect_passthrough;
245   gint i;
246
247   fail_unless (g_list_length (buffers) == 0);
248
249   input_sample = 1.0;
250   input_buf = test_buffer_new (input_sample);
251
252   /* We keep an extra reference to detect passthrough mode. */
253   gst_buffer_ref (input_buf);
254   /* Pushing steals a reference. */
255   fail_unless (gst_pad_push (mysrcpad, input_buf) == GST_FLOW_OK);
256   gst_buffer_unref (input_buf);
257
258   /* The output buffer ends up on the global buffer list. */
259   fail_unless (g_list_length (buffers) == 1);
260   output_buf = buffers->data;
261   fail_if (output_buf == NULL);
262
263   buffers = g_list_remove (buffers, output_buf);
264   ASSERT_BUFFER_REFCOUNT (output_buf, "output_buf", 1);
265
266   fail_unless_equals_int (gst_buffer_get_size (output_buf),
267       8 * sizeof (gfloat));
268
269   data = gst_buffer_map (output_buf, NULL, NULL, GST_MAP_READ);
270
271   output_sample = *data;
272   fail_if (output_sample == 0.0, "First output sample is zero");
273   for (i = 1; i < 8; i++) {
274     fail_unless (output_sample == data[i], "Output samples not uniform");
275   };
276   gst_buffer_unmap (output_buf, data, -1);
277
278   gain = 20. * log10 (output_sample / input_sample);
279   fail_unless (MATCH_GAIN (gain, expected_gain),
280       "Applied gain is %.2f dB, expected %.2f dB", gain, expected_gain);
281   g_object_get (element, "result-gain", &prop_gain, NULL);
282   fail_unless (MATCH_GAIN (prop_gain, expected_gain),
283       "Result gain is %.2f dB, expected %.2f dB", prop_gain, expected_gain);
284
285   is_passthrough = (output_buf == input_buf);
286   expect_passthrough = MATCH_GAIN (expected_gain, +0.00);
287   fail_unless (is_passthrough == expect_passthrough,
288       expect_passthrough
289       ? "Expected operation in passthrough mode"
290       : "Incorrect passthrough behaviour");
291
292   gst_buffer_unref (output_buf);
293 }
294
295 static void
296 fail_unless_gain (GstElement * element, gdouble expected_gain)
297 {
298   fail_unless_target_gain (element, expected_gain);
299   fail_unless_result_gain (element, expected_gain);
300 }
301
302 /* Start of tests. */
303
304 GST_START_TEST (test_no_buffer)
305 {
306   GstElement *element = setup_rgvolume ();
307
308   set_playing_state (element);
309   set_null_state (element);
310   set_playing_state (element);
311   send_eos_event (element);
312
313   cleanup_rgvolume (element);
314 }
315
316 GST_END_TEST;
317
318 GST_START_TEST (test_events)
319 {
320   GstElement *element = setup_rgvolume ();
321   GstEvent *event;
322   GstEvent *new_event;
323   GstTagList *tag_list;
324   gchar *artist;
325
326   set_playing_state (element);
327
328   send_newsegment_and_empty_buffer ();
329
330   tag_list = gst_tag_list_new_empty ();
331   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
332       GST_TAG_TRACK_GAIN, +4.95, GST_TAG_TRACK_PEAK, 0.59463,
333       GST_TAG_ALBUM_GAIN, -1.54, GST_TAG_ALBUM_PEAK, 0.693415,
334       GST_TAG_ARTIST, "Foobar", NULL);
335   event = gst_event_new_tag (tag_list);
336   new_event = send_tag_event (element, event);
337   /* Expect the element to modify the writable event. */
338   fail_unless (event == new_event, "Writable tag event not reused");
339   gst_event_parse_tag (new_event, &tag_list);
340   fail_unless (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist));
341   fail_unless (g_str_equal (artist, "Foobar"));
342   g_free (artist);
343   gst_event_unref (new_event);
344
345   /* Same as above, but with a non-writable event. */
346
347   tag_list = gst_tag_list_new_empty ();
348   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
349       GST_TAG_TRACK_GAIN, +4.95, GST_TAG_TRACK_PEAK, 0.59463,
350       GST_TAG_ALBUM_GAIN, -1.54, GST_TAG_ALBUM_PEAK, 0.693415,
351       GST_TAG_ARTIST, "Foobar", NULL);
352   event = gst_event_new_tag (tag_list);
353   /* Holding an extra ref makes the event unwritable: */
354   gst_event_ref (event);
355   new_event = send_tag_event (element, event);
356   fail_unless (event != new_event, "Unwritable tag event reused");
357   gst_event_parse_tag (new_event, &tag_list);
358   fail_unless (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist));
359   fail_unless (g_str_equal (artist, "Foobar"));
360   g_free (artist);
361   gst_event_unref (event);
362   gst_event_unref (new_event);
363
364   cleanup_rgvolume (element);
365 }
366
367 GST_END_TEST;
368
369 GST_START_TEST (test_simple)
370 {
371   GstElement *element = setup_rgvolume ();
372   GstTagList *tag_list;
373
374   g_object_set (element, "album-mode", FALSE, "headroom", +0.00,
375       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
376   set_playing_state (element);
377
378   send_newsegment_and_empty_buffer ();
379
380   tag_list = gst_tag_list_new_empty ();
381   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
382       GST_TAG_TRACK_GAIN, -3.45, GST_TAG_TRACK_PEAK, 1.0,
383       GST_TAG_ALBUM_GAIN, +2.09, GST_TAG_ALBUM_PEAK, 1.0, NULL);
384   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
385   fail_unless_gain (element, -9.45);    /* pre-amp + track gain */
386   send_eos_event (element);
387
388   g_object_set (element, "album-mode", TRUE, NULL);
389
390   tag_list = gst_tag_list_new_empty ();
391   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
392       GST_TAG_TRACK_GAIN, -3.45, GST_TAG_TRACK_PEAK, 1.0,
393       GST_TAG_ALBUM_GAIN, +2.09, GST_TAG_ALBUM_PEAK, 1.0, NULL);
394   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
395   fail_unless_gain (element, -3.91);    /* pre-amp + album gain */
396
397   /* Switching back to track mode in the middle of a stream: */
398   g_object_set (element, "album-mode", FALSE, NULL);
399   fail_unless_gain (element, -9.45);    /* pre-amp + track gain */
400   send_eos_event (element);
401
402   cleanup_rgvolume (element);
403 }
404
405 GST_END_TEST;
406
407 /* If there are no gain tags at all, the fallback gain is used. */
408
409 GST_START_TEST (test_fallback_gain)
410 {
411   GstElement *element = setup_rgvolume ();
412   GstTagList *tag_list;
413
414   /* First some track where fallback does _not_ apply. */
415
416   g_object_set (element, "album-mode", FALSE, "headroom", 10.00,
417       "pre-amp", -6.00, "fallback-gain", -3.00, NULL);
418   set_playing_state (element);
419
420   send_newsegment_and_empty_buffer ();
421
422   tag_list = gst_tag_list_new_empty ();
423   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
424       GST_TAG_TRACK_GAIN, +3.5, GST_TAG_TRACK_PEAK, 1.0,
425       GST_TAG_ALBUM_GAIN, -0.5, GST_TAG_ALBUM_PEAK, 1.0, NULL);
426   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
427   fail_unless_gain (element, -2.50);    /* pre-amp + track gain */
428   send_eos_event (element);
429
430   /* Now a track completely missing tags. */
431
432   fail_unless_gain (element, -9.00);    /* pre-amp + fallback-gain */
433
434   /* Changing the fallback gain in the middle of a stream, going to pass-through
435    * mode: */
436   g_object_set (element, "fallback-gain", +6.00, NULL);
437   fail_unless_gain (element, +0.00);    /* pre-amp + fallback-gain */
438   send_eos_event (element);
439
440   /* Verify that result gain is set to +0.00 with pre-amp + fallback-gain >
441    * +0.00 and no headroom. */
442
443   g_object_set (element, "fallback-gain", +12.00, "headroom", +0.00, NULL);
444   fail_unless_target_gain (element, +6.00);     /* pre-amp + fallback-gain */
445   fail_unless_result_gain (element, +0.00);
446   send_eos_event (element);
447
448   cleanup_rgvolume (element);
449 }
450
451 GST_END_TEST;
452
453 /* If album gain is to be preferred but not available, the track gain is to be
454  * taken instead. */
455
456 GST_START_TEST (test_fallback_track)
457 {
458   GstElement *element = setup_rgvolume ();
459   GstTagList *tag_list;
460
461   g_object_set (element, "album-mode", TRUE, "headroom", +0.00,
462       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
463   set_playing_state (element);
464
465   send_newsegment_and_empty_buffer ();
466
467   tag_list = gst_tag_list_new_empty ();
468   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
469       GST_TAG_TRACK_GAIN, +2.11, GST_TAG_TRACK_PEAK, 1.0, NULL);
470   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
471   fail_unless_gain (element, -3.89);    /* pre-amp + track gain */
472
473   send_eos_event (element);
474
475   cleanup_rgvolume (element);
476 }
477
478 GST_END_TEST;
479
480 /* If track gain is to be preferred but not available, the album gain is to be
481  * taken instead. */
482
483 GST_START_TEST (test_fallback_album)
484 {
485   GstElement *element = setup_rgvolume ();
486   GstTagList *tag_list;
487
488   g_object_set (element, "album-mode", FALSE, "headroom", +0.00,
489       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
490   set_playing_state (element);
491
492   send_newsegment_and_empty_buffer ();
493
494   tag_list = gst_tag_list_new_empty ();
495   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
496       GST_TAG_ALBUM_GAIN, +3.73, GST_TAG_ALBUM_PEAK, 1.0, NULL);
497   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
498   fail_unless_gain (element, -2.27);    /* pre-amp + album gain */
499
500   send_eos_event (element);
501
502   cleanup_rgvolume (element);
503 }
504
505 GST_END_TEST;
506
507 GST_START_TEST (test_headroom)
508 {
509   GstElement *element = setup_rgvolume ();
510   GstTagList *tag_list;
511
512   g_object_set (element, "album-mode", FALSE, "headroom", +0.00,
513       "pre-amp", +0.00, "fallback-gain", +1.23, NULL);
514   set_playing_state (element);
515
516   send_newsegment_and_empty_buffer ();
517
518   tag_list = gst_tag_list_new_empty ();
519   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
520       GST_TAG_TRACK_GAIN, +3.50, GST_TAG_TRACK_PEAK, 1.0, NULL);
521   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
522   fail_unless_target_gain (element, +3.50);     /* pre-amp + track gain */
523   fail_unless_result_gain (element, +0.00);
524   send_eos_event (element);
525
526   g_object_set (element, "headroom", +2.00, NULL);
527   tag_list = gst_tag_list_new_empty ();
528   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
529       GST_TAG_TRACK_GAIN, +9.18, GST_TAG_TRACK_PEAK, 0.687149, NULL);
530   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
531   fail_unless_target_gain (element, +9.18);     /* pre-amp + track gain */
532   /* Result is 20. * log10 (1. / peak) + headroom. */
533   fail_unless_result_gain (element, 5.2589816238303335);
534   send_eos_event (element);
535
536   g_object_set (element, "album-mode", TRUE, NULL);
537   tag_list = gst_tag_list_new_empty ();
538   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
539       GST_TAG_ALBUM_GAIN, +5.50, GST_TAG_ALBUM_PEAK, 1.0, NULL);
540   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
541   fail_unless_target_gain (element, +5.50);     /* pre-amp + album gain */
542   fail_unless_result_gain (element, +2.00);     /* headroom */
543   send_eos_event (element);
544
545   cleanup_rgvolume (element);
546 }
547
548 GST_END_TEST;
549
550 GST_START_TEST (test_reference_level)
551 {
552   GstElement *element = setup_rgvolume ();
553   GstTagList *tag_list;
554
555   g_object_set (element,
556       "album-mode", FALSE,
557       "headroom", +0.00, "pre-amp", +0.00, "fallback-gain", +1.23, NULL);
558   set_playing_state (element);
559
560   send_newsegment_and_empty_buffer ();
561
562   tag_list = gst_tag_list_new_empty ();
563   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
564       GST_TAG_TRACK_GAIN, 0.00, GST_TAG_TRACK_PEAK, 0.2,
565       GST_TAG_REFERENCE_LEVEL, 83., NULL);
566   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
567   /* Because our authorative reference is 89 dB, we bump it up by +6 dB. */
568   fail_unless_gain (element, +6.00);    /* pre-amp + track gain */
569   send_eos_event (element);
570
571   g_object_set (element, "album-mode", TRUE, NULL);
572
573   /* Same as above, but with album gain. */
574
575   tag_list = gst_tag_list_new_empty ();
576   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
577       GST_TAG_TRACK_GAIN, 1.23, GST_TAG_TRACK_PEAK, 0.1,
578       GST_TAG_ALBUM_GAIN, 0.00, GST_TAG_ALBUM_PEAK, 0.2,
579       GST_TAG_REFERENCE_LEVEL, 83., NULL);
580   fail_unless (send_tag_event (element, gst_event_new_tag (tag_list)) == NULL);
581   fail_unless_gain (element, +6.00);    /* pre-amp + album gain */
582
583   cleanup_rgvolume (element);
584 }
585
586 GST_END_TEST;
587
588 static Suite *
589 rgvolume_suite (void)
590 {
591   Suite *s = suite_create ("rgvolume");
592   TCase *tc_chain = tcase_create ("general");
593
594   suite_add_tcase (s, tc_chain);
595
596   tcase_add_test (tc_chain, test_no_buffer);
597   tcase_add_test (tc_chain, test_events);
598   tcase_add_test (tc_chain, test_simple);
599   tcase_add_test (tc_chain, test_fallback_gain);
600   tcase_add_test (tc_chain, test_fallback_track);
601   tcase_add_test (tc_chain, test_fallback_album);
602   tcase_add_test (tc_chain, test_headroom);
603   tcase_add_test (tc_chain, test_reference_level);
604
605   return s;
606 }
607
608 int
609 main (int argc, char **argv)
610 {
611   gint nf;
612
613   Suite *s = rgvolume_suite ();
614   SRunner *sr = srunner_create (s);
615
616   gst_check_init (&argc, &argv);
617
618   srunner_run_all (sr, CK_ENV);
619   nf = srunner_ntests_failed (sr);
620   srunner_free (sr);
621
622   return nf;
623 }