diff options
author | Max Kellermann <max@duempel.org> | 2009-12-31 18:20:08 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-31 18:32:09 +0100 |
commit | 05cde5810accc64b4f57a106ad41ba46dfd99bbd (patch) | |
tree | 401baa007b179882fe242fb0641f30ccd89a1b3d /src/decoder/mp4ff_plugin.c | |
parent | 6b96f5d566a6a36bfcdb70c8a27771717eb3d038 (diff) | |
download | mpd-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/mp4ff_plugin.c | 19 |
1 files changed, 4 insertions, 15 deletions
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, }; |