From 05cde5810accc64b4f57a106ad41ba46dfd99bbd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Dec 2009 18:20:08 +0100 Subject: decoder: switch a bunch of plugins to stream_tag() This patch changes the following decoder plugins to implement stream_tag() instead of tag_dup(): faad, ffmpeg, mad, modplug, mp4ff, mpcdec, oggflac This simplifies their code, because they do not need to take care of opening/closing the stream. --- src/decoder/oggflac_plugin.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/decoder/oggflac_plugin.c') diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c index b8b087b47..6aa9818f1 100644 --- a/src/decoder/oggflac_plugin.c +++ b/src/decoder/oggflac_plugin.c @@ -243,33 +243,20 @@ fail: /* public functions: */ static struct tag * -oggflac_tag_dup(const char *file) +oggflac_stream_tag(struct input_stream *is) { - GError *error = NULL; - struct input_stream input_stream; OggFLAC__SeekableStreamDecoder *decoder; struct flac_data data; struct tag *tag; - if (!input_stream_open(&input_stream, file, &error)) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } - - return NULL; - } - - if (ogg_stream_type_detect(&input_stream) != FLAC) { - input_stream_close(&input_stream); + if (ogg_stream_type_detect(is) != FLAC) return NULL; - } /* rewind the stream, because ogg_stream_type_detect() has moved it */ - input_stream_seek(&input_stream, 0, SEEK_SET, NULL); + input_stream_seek(is, 0, SEEK_SET, NULL); - flac_data_init(&data, NULL, &input_stream); + flac_data_init(&data, NULL, is); data.tag = tag_new(); @@ -278,7 +265,6 @@ oggflac_tag_dup(const char *file) decoder = full_decoder_init_and_read_metadata(&data, 1); oggflac_cleanup(decoder); - input_stream_close(&input_stream); if (tag_is_defined(data.tag)) { tag = data.tag; @@ -362,7 +348,7 @@ static const char *const oggflac_mime_types[] = { const struct decoder_plugin oggflac_decoder_plugin = { .name = "oggflac", .stream_decode = oggflac_decode, - .tag_dup = oggflac_tag_dup, + .stream_tag = oggflac_stream_tag, .suffixes = oggflac_suffixes, .mime_types = oggflac_mime_types }; -- cgit v1.2.3