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.
This commit is contained in:
Max Kellermann 2008-11-10 14:39:42 +01:00
parent 505959f74d
commit 0e87f85598

View File

@ -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[] = {