aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/flac_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-11 18:56:10 +0100
committerMax Kellermann <max@duempel.org>2009-11-11 19:07:30 +0100
commita3f5284dc6728321feb6efb1ade91855a9a90afa (patch)
treeecf3cb6dc460fd605d3b1dd6f2924d66e83a0aa1 /src/decoder/flac_plugin.c
parent4a8cc87b4d6e57f2149bd60f48f9a1b69c454593 (diff)
downloadmpd-a3f5284dc6728321feb6efb1ade91855a9a90afa.tar.gz
mpd-a3f5284dc6728321feb6efb1ade91855a9a90afa.tar.xz
mpd-a3f5284dc6728321feb6efb1ade91855a9a90afa.zip
decoder/flac: merged code into flac_decoder_new()
Convenience wrapper for FLAC__stream_decoder_new() and FLAC__stream_decoder_set_metadata_respond().
Diffstat (limited to '')
-rw-r--r--src/decoder/flac_plugin.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index c7be1b81b..774d40df1 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -371,6 +371,26 @@ flac_tag_dup(const char *file)
return flac_tag_load(file, NULL);
}
+/**
+ * Some glue code around FLAC__stream_decoder_new().
+ */
+static FLAC__StreamDecoder *
+flac_decoder_new(void)
+{
+ FLAC__StreamDecoder *sd = FLAC__stream_decoder_new();
+ if (sd == NULL) {
+ g_warning("FLAC__stream_decoder_new() failed");
+ return NULL;
+ }
+
+#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
+ if(!FLAC__stream_decoder_set_metadata_respond(sd, FLAC__METADATA_TYPE_VORBIS_COMMENT))
+ g_debug("FLAC__stream_decoder_set_metadata_respond() has failed");
+#endif
+
+ return sd;
+}
+
static void
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
FLAC__uint64 t_start, FLAC__uint64 t_end)
@@ -431,18 +451,13 @@ flac_decode_internal(struct decoder * decoder,
struct flac_data data;
const char *err = NULL;
- if (!(flac_dec = FLAC__stream_decoder_new()))
+ flac_dec = flac_decoder_new();
+ if (flac_dec == NULL)
return;
+
flac_data_init(&data, decoder, input_stream);
data.tag = tag_new();
-#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
- if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
- {
- g_debug("Failed to set metadata respond\n");
- }
-#endif
-
if (is_ogg) {
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
FLAC__StreamDecoderInitStatus status =
@@ -564,21 +579,12 @@ flac_container_decode(struct decoder* decoder,
return;
}
- if (!(flac_dec = FLAC__stream_decoder_new()))
- {
- g_free(pathname);
+ flac_dec = flac_decoder_new();
+ if (flac_dec == NULL)
return;
- }
flac_data_init(&data, decoder, NULL);
-#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
- if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
- {
- g_debug("Failed to set metadata respond\n");
- }
-#endif
-
init_status = is_ogg
? FLAC__stream_decoder_init_ogg_file(flac_dec, pathname,
flac_write_cb,
@@ -645,19 +651,12 @@ flac_filedecode_internal(struct decoder* decoder,
const char *err = NULL;
unsigned int flac_err_state = 0;
- if (!(flac_dec = FLAC__stream_decoder_new()))
+ flac_dec = flac_decoder_new();
+ if (flac_dec == NULL)
return;
flac_data_init(&data, decoder, NULL);
-#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
- if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
- {
- g_debug("Failed to set metadata respond\n");
- }
-#endif
-
-
if (is_ogg)
{
if ( (flac_err_state = FLAC__stream_decoder_init_ogg_file( flac_dec,