aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mad_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-31 18:20:08 +0100
committerMax Kellermann <max@duempel.org>2009-12-31 18:32:09 +0100
commit05cde5810accc64b4f57a106ad41ba46dfd99bbd (patch)
tree401baa007b179882fe242fb0641f30ccd89a1b3d /src/decoder/mad_plugin.c
parent6b96f5d566a6a36bfcdb70c8a27771717eb3d038 (diff)
downloadmpd-05cde5810accc64b4f57a106ad41ba46dfd99bbd.tar.gz
mpd-05cde5810accc64b4f57a106ad41ba46dfd99bbd.tar.xz
mpd-05cde5810accc64b4f57a106ad41ba46dfd99bbd.zip
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.
Diffstat (limited to '')
-rw-r--r--src/decoder/mad_plugin.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/decoder/mad_plugin.c b/src/decoder/mad_plugin.c
index f23ab3c21..e68ba688f 100644
--- a/src/decoder/mad_plugin.c
+++ b/src/decoder/mad_plugin.c
@@ -914,21 +914,18 @@ static void mp3_data_finish(struct mp3_data *data)
}
/* this is primarily used for getting total time for tags */
-static int mp3_total_file_time(const char *file)
+static int
+mad_decoder_total_file_time(struct input_stream *is)
{
- struct input_stream input_stream;
struct mp3_data data;
int ret;
- if (!input_stream_open(&input_stream, file, NULL))
- return -1;
- mp3_data_init(&data, NULL, &input_stream);
+ mp3_data_init(&data, NULL, is);
if (!mp3_decode_first_frame(&data, NULL, NULL))
ret = -1;
else
ret = data.total_time + 0.5;
mp3_data_finish(&data);
- input_stream_close(&input_stream);
return ret;
}
@@ -1222,16 +1219,15 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
mp3_data_finish(&data);
}
-static struct tag *mp3_tag_dup(const char *file)
+static struct tag *
+mad_decoder_stream_tag(struct input_stream *is)
{
struct tag *tag;
int total_time;
- total_time = mp3_total_file_time(file);
- if (total_time < 0) {
- g_debug("Failed to get total song time from: %s", file);
+ total_time = mad_decoder_total_file_time(is);
+ if (total_time < 0)
return NULL;
- }
tag = tag_new();
tag->time = total_time;
@@ -1245,7 +1241,7 @@ const struct decoder_plugin mad_decoder_plugin = {
.name = "mad",
.init = mp3_plugin_init,
.stream_decode = mp3_decode,
- .tag_dup = mp3_tag_dup,
+ .stream_tag = mad_decoder_stream_tag,
.suffixes = mp3_suffixes,
.mime_types = mp3_mime_types
};