From 7e2eef475171d77f55c76ecf3301ee4310b34f63 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 17 Dec 2018 15:12:01 +0100 Subject: [PATCH] [tests] sync test-sink_vorbis --- tests/src/io/test-sink_vorbis.c | 101 +++++++++++----------------------------- 1 file changed, 27 insertions(+), 74 deletions(-) diff --git a/tests/src/io/test-sink_vorbis.c b/tests/src/io/test-sink_vorbis.c index ab123cc6..fe6bb2b0 100644 --- a/tests/src/io/test-sink_vorbis.c +++ b/tests/src/io/test-sink_vorbis.c @@ -2,93 +2,46 @@ #include #include "utils_tests.h" -#if 1 // test without inclusion in headers +#define aubio_sink_custom "vorbis" + +#ifdef HAVE_VORBISENC +// functions not exposed in the headers, declared here typedef struct _aubio_sink_vorbis_t aubio_sink_vorbis_t; extern aubio_sink_vorbis_t * new_aubio_sink_vorbis(const char_t *uri, uint_t samplerate); extern void del_aubio_sink_vorbis (aubio_sink_vorbis_t *s); extern uint_t aubio_sink_vorbis_open(aubio_sink_vorbis_t *s); +extern uint_t aubio_sink_vorbis_close(aubio_sink_vorbis_t *s); extern uint_t aubio_sink_vorbis_preset_channels(aubio_sink_vorbis_t *s, uint_t channels); extern uint_t aubio_sink_vorbis_preset_samplerate(aubio_sink_vorbis_t *s, uint_t samplerate); +extern void aubio_sink_vorbis_do(aubio_sink_vorbis_t *s, fvec_t *write_data, + uint_t write); +extern void aubio_sink_vorbis_do_multi(aubio_sink_vorbis_t *s, + fmat_t *write_data, uint_t write); extern uint_t aubio_sink_vorbis_get_channels(aubio_sink_vorbis_t *s); extern uint_t aubio_sink_vorbis_get_samplerate(aubio_sink_vorbis_t *s); -extern void aubio_sink_vorbis_do_multi(aubio_sink_vorbis_t *s, fmat_t* - write_data, uint_t write); -#endif - -// this file uses the unstable aubio api to test aubio_sink_vorbis, please -// use aubio_sink instead see src/io/sink.h and tests/src/sink/test-sink.c - -int main (int argc, char **argv) -{ - sint_t err = 0; - - if (argc < 3) { - PRINT_ERR("not enough arguments, running tests\n"); - err = run_on_default_source_and_sink(main); - PRINT_MSG("usage: %s [samplerate] [channels] [hop_size]\n", argv[0]); - return err; - } - -#ifdef HAVE_VORBISENC - uint_t samplerate = 0; - uint_t channels = 0; - uint_t hop_size = 512; - uint_t n_frames = 0, read = 0; - char_t *source_path = argv[1]; - char_t *sink_path = argv[2]; - - if ( argc >= 4 ) samplerate = atoi(argv[3]); - if ( argc >= 5 ) channels = atoi(argv[4]); - if ( argc >= 6 ) hop_size = atoi(argv[5]); - if ( argc >= 7 ) { - err = 2; - PRINT_ERR("too many arguments\n"); - return err; - } - - aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); - if (!i) { err = 1; goto beach_source; } - - if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); - if (channels == 0 ) channels = aubio_source_get_channels(i); - - fmat_t *mat = new_fmat(channels, hop_size); - if (!mat) { err = 1; goto beach_fmat; } - - aubio_sink_vorbis_t *o = new_aubio_sink_vorbis(sink_path, 0); - if (!o) { err = 1; goto beach_sink; } - err = aubio_sink_vorbis_preset_samplerate(o, samplerate); - if (err) { goto beach; } - err = aubio_sink_vorbis_preset_channels(o, channels); - if (err) { goto beach; } +#define HAVE_AUBIO_SINK_CUSTOM +#define aubio_sink_custom_t aubio_sink_vorbis_t +#define new_aubio_sink_custom new_aubio_sink_vorbis +#define del_aubio_sink_custom del_aubio_sink_vorbis +#define aubio_sink_custom_do aubio_sink_vorbis_do +#define aubio_sink_custom_do_multi aubio_sink_vorbis_do_multi +#define aubio_sink_custom_close aubio_sink_vorbis_close +#define aubio_sink_custom_preset_samplerate aubio_sink_vorbis_preset_samplerate +#define aubio_sink_custom_preset_channels aubio_sink_vorbis_preset_channels +#define aubio_sink_custom_get_samplerate aubio_sink_vorbis_get_samplerate +#define aubio_sink_custom_get_channels aubio_sink_vorbis_get_channels +#endif /* HAVE_VORBISENC */ - do { - aubio_source_do_multi(i, mat, &read); - aubio_sink_vorbis_do_multi(o, mat, read); - n_frames += read; - } while ( read == hop_size ); +#include "base-sink_custom.h" - PRINT_MSG("read %d frames at %dHz in %d channels (%d blocks) from %s written to %s\n", - n_frames, samplerate, channels, n_frames / hop_size, - source_path, sink_path); - PRINT_MSG("wrote %s with %dHz in %d channels\n", sink_path, - aubio_sink_vorbis_get_samplerate(o), - aubio_sink_vorbis_get_channels(o) ); +// this file uses the unstable aubio api, please use aubio_sink instead +// see src/io/sink.h and tests/src/sink/test-sink.c -beach: - del_aubio_sink_vorbis(o); -beach_sink: - del_fmat(mat); -beach_fmat: - del_aubio_source(i); -beach_source: -#else /* HAVE_VORBISENC */ - err = 0; - PRINT_ERR("aubio was not compiled with aubio_sink_vorbis\n"); -#endif /* HAVE_VORBISENC */ - return err; +int main (int argc, char **argv) +{ + return base_main(argc, argv); } -- 2.11.0