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