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/mp4ff_plugin.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/decoder/mp4ff_plugin.c') diff --git a/src/decoder/mp4ff_plugin.c b/src/decoder/mp4ff_plugin.c index 325a97291..9975e511c 100644 --- a/src/decoder/mp4ff_plugin.c +++ b/src/decoder/mp4ff_plugin.c @@ -337,13 +337,12 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) } static struct tag * -mp4_tag_dup(const char *file) +mp4_stream_tag(struct input_stream *is) { struct tag *ret = NULL; - struct input_stream input_stream; struct mp4_context ctx = { .decoder = NULL, - .input_stream = &input_stream, + .input_stream = is, }; mp4ff_callback_t callback = { .read = mp4_read, @@ -356,21 +355,13 @@ mp4_tag_dup(const char *file) int32_t scale; int i; - if (!input_stream_open(&input_stream, file, NULL)) { - g_warning("Failed to open file: %s", file); - return NULL; - } - mp4fh = mp4ff_open_read(&callback); - if (!mp4fh) { - input_stream_close(&input_stream); + if (mp4fh == NULL) return NULL; - } track = mp4_get_aac_track(mp4fh, NULL, NULL, NULL); if (track < 0) { mp4ff_close(mp4fh); - input_stream_close(&input_stream); return NULL; } @@ -379,7 +370,6 @@ mp4_tag_dup(const char *file) scale = mp4ff_time_scale(mp4fh, track); if (scale < 0) { mp4ff_close(mp4fh); - input_stream_close(&input_stream); tag_free(ret); return NULL; } @@ -415,7 +405,6 @@ mp4_tag_dup(const char *file) } mp4ff_close(mp4fh); - input_stream_close(&input_stream); return ret; } @@ -426,7 +415,7 @@ static const char *const mp4_mime_types[] = { "audio/mp4", "audio/m4a", NULL }; const struct decoder_plugin mp4ff_decoder_plugin = { .name = "mp4", .stream_decode = mp4_decode, - .tag_dup = mp4_tag_dup, + .stream_tag = mp4_stream_tag, .suffixes = mp4_suffixes, .mime_types = mp4_mime_types, }; -- cgit v1.2.3