From: Paul Brossier Date: Thu, 13 Dec 2018 01:42:24 +0000 (+0100) Subject: [sink] search extension once X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=2de7cfa1ef917588db5cc898b6614674065cfa7d;p=aubio.git [sink] search extension once --- diff --git a/src/io/sink.c b/src/io/sink.c index d19ad02e..178937dd 100644 --- a/src/io/sink.c +++ b/src/io/sink.c @@ -101,11 +101,14 @@ static const char_t *aubio_get_extension(const char_t *filename) aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) { aubio_sink_t * s = AUBIO_NEW(aubio_sink_t); +#if defined(HAVE_VORBISENC) || defined(HAVE_FLAC) + const char_t * uri_ext = aubio_get_extension(uri); +#endif /* defined(HAVE_VORBISENC) || defined(HAVE_FLAC) */ #ifdef HAVE_VORBISENC // check if this uri could be for us uint_t match_oggstream = 0; - if (strcmp (aubio_get_extension(uri), "ogg") == 0) match_oggstream = 1; + if (strcmp (uri_ext, "ogg") == 0) match_oggstream = 1; if (match_oggstream) { s->sink = (void *)new_aubio_sink_vorbis(uri, samplerate); if (s->sink) { @@ -125,7 +128,7 @@ aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) { #ifdef HAVE_FLAC // check if this uri could be for us uint_t match_flacstream = 0; - if (strcmp (aubio_get_extension(uri), "flac") == 0) match_flacstream = 1; + if (strcmp (uri_ext, "flac") == 0) match_flacstream = 1; if (match_flacstream) { s->sink = (void *)new_aubio_sink_flac(uri, samplerate); if (s->sink) { @@ -186,7 +189,9 @@ aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) { #endif /* HAVE_WAVWRITE */ #if !defined(HAVE_WAVWRITE) && \ !defined(HAVE_SNDFILE) && \ - !defined(HAVE_SINK_APPLE_AUDIO) + !defined(HAVE_SINK_APPLE_AUDIO) && \ + !defined(HAVE_VORBISENC) && \ + !defined(HAVE_FLAC) AUBIO_ERROR("sink: failed creating '%s' at %dHz (no sink built-in)\n", uri, samplerate); #endif AUBIO_FREE(s);