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/mpcdec_plugin.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/decoder/mpcdec_plugin.c') diff --git a/src/decoder/mpcdec_plugin.c b/src/decoder/mpcdec_plugin.c index a186bc368..c4f4fae03 100644 --- a/src/decoder/mpcdec_plugin.c +++ b/src/decoder/mpcdec_plugin.c @@ -275,9 +275,8 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) } static float -mpcdec_get_file_duration(const char *file) +mpcdec_get_file_duration(struct input_stream *is) { - struct input_stream is; float total_time = -1; mpc_reader reader; @@ -287,10 +286,7 @@ mpcdec_get_file_duration(const char *file) mpc_streaminfo info; struct mpc_decoder_data data; - if (!input_stream_open(&is, file, NULL)) - return -1; - - data.is = &is; + data.is = is; data.decoder = NULL; reader.read = mpc_read_cb; @@ -303,16 +299,12 @@ mpcdec_get_file_duration(const char *file) #ifdef MPC_IS_OLD_API mpc_streaminfo_init(&info); - if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { - input_stream_close(&is); + if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) return -1; - } #else demux = mpc_demux_init(&reader); - if (demux == NULL) { - input_stream_close(&is); + if (demux == NULL) return -1; - } mpc_demux_get_info(demux, &info); mpc_demux_exit(demux); @@ -320,21 +312,17 @@ mpcdec_get_file_duration(const char *file) total_time = mpc_streaminfo_get_length(&info); - input_stream_close(&is); - return total_time; } static struct tag * -mpcdec_tag_dup(const char *file) +mpcdec_stream_tag(struct input_stream *is) { - float total_time = mpcdec_get_file_duration(file); + float total_time = mpcdec_get_file_duration(is); struct tag *tag; - if (total_time < 0) { - g_debug("Failed to get duration of file: %s", file); + if (total_time < 0) return NULL; - } tag = tag_new(); tag->time = total_time; @@ -346,6 +334,6 @@ static const char *const mpcdec_suffixes[] = { "mpc", NULL }; const struct decoder_plugin mpcdec_decoder_plugin = { .name = "mpcdec", .stream_decode = mpcdec_decode, - .tag_dup = mpcdec_tag_dup, + .stream_tag = mpcdec_stream_tag, .suffixes = mpcdec_suffixes, }; -- cgit v1.2.3