From 0e87f85598333c6e88ab115ebae15389fc23214a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 10 Nov 2008 14:39:42 +0100 Subject: flac: enable the oggflac plugin with older libflac versions Since decoder_list.c does not include the libflac headers, it cannot know whether to add the oggflac plugin to the decoder list. Solve this by always enabling the oggflac sub-plugin, even with older libflac versions. When the libflac API cannot support oggflac, disable the plugin at runtime by returning "false" from its init() method. --- src/decoder/flac_plugin.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index e574315b3..a24c97a95 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -385,14 +385,21 @@ flac_decode(struct decoder * decoder, struct input_stream *inStream) return flac_decode_internal(decoder, inStream, false); } +#ifndef HAVE_OGGFLAC + static bool oggflac_init(void) { +#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 return !!FLAC_API_SUPPORTS_OGG_FLAC; +#else + /* disable oggflac when libflac is too old */ + return false; +#endif } -#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 && \ - !defined(HAVE_OGGFLAC) +#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 + static struct tag *oggflac_tag_dup(const char *file) { struct tag *ret = NULL; @@ -443,17 +450,21 @@ static const char *const oggflac_mime_types[] = { NULL }; +#endif /* FLAC_API_VERSION_CURRENT >= 7 */ + const struct decoder_plugin oggflacPlugin = { .name = "oggflac", .init = oggflac_init, +#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 .try_decode = oggflac_try_decode, .stream_decode = oggflac_decode, .tag_dup = oggflac_tag_dup, .suffixes = oggflac_suffixes, .mime_types = oggflac_mime_types +#endif }; -#endif /* FLAC_API_VERSION_CURRENT >= 7 */ +#endif /* HAVE_OGGFLAC */ static const char *const flacSuffixes[] = { "flac", NULL }; static const char *const flac_mime_types[] = { -- cgit v1.2.3