diff options
author | Max Kellermann <max@duempel.org> | 2012-02-11 19:12:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-02-11 17:04:29 +0100 |
commit | 5d73215a8dad922c8e383f3837f3ec9e26503389 (patch) | |
tree | 8fc4b96d93a907054a05d3250f97bf4f68c6df85 /src/decoder/vorbis_decoder_plugin.c | |
parent | b7356bc526dbbd6fa00d40caff2addec10ae7c7e (diff) | |
download | mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.gz mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.xz mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.zip |
decoder_plugin: scan tags with callback table
Pass a callback table to scan_file() and scan_stream(), instead of
returning a tag object.
Diffstat (limited to 'src/decoder/vorbis_decoder_plugin.c')
-rw-r--r-- | src/decoder/vorbis_decoder_plugin.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/decoder/vorbis_decoder_plugin.c b/src/decoder/vorbis_decoder_plugin.c index f34693844..15cdc0ca9 100644 --- a/src/decoder/vorbis_decoder_plugin.c +++ b/src/decoder/vorbis_decoder_plugin.c @@ -22,6 +22,7 @@ #include "_ogg_common.h" #include "audio_check.h" #include "uri.h" +#include "tag_handler.h" #ifndef HAVE_TREMOR #define OV_EXCLUDE_STATIC_CALLBACKS @@ -268,24 +269,24 @@ vorbis_stream_decode(struct decoder *decoder, ov_clear(&vf); } -static struct tag * -vorbis_stream_tag(struct input_stream *is) +static bool +vorbis_scan_stream(struct input_stream *is, + const struct tag_handler *handler, void *handler_ctx) { struct vorbis_input_stream vis; OggVorbis_File vf; if (!vorbis_is_open(&vis, &vf, NULL, is)) - return NULL; + return false; - struct tag *tag = vorbis_comments_to_tag(ov_comment(&vf, -1)->user_comments); + tag_handler_invoke_duration(handler, handler_ctx, + (int)(ov_time_total(&vf, -1) + 0.5)); - if (tag == NULL) - tag = tag_new(); - tag->time = (int)(ov_time_total(&vf, -1) + 0.5); + vorbis_comments_scan(ov_comment(&vf, -1)->user_comments, + handler, handler_ctx); ov_clear(&vf); - - return tag; + return true; } static const char *const vorbis_suffixes[] = { @@ -307,7 +308,7 @@ static const char *const vorbis_mime_types[] = { const struct decoder_plugin vorbis_decoder_plugin = { .name = "vorbis", .stream_decode = vorbis_stream_decode, - .stream_tag = vorbis_stream_tag, + .scan_stream = vorbis_scan_stream, .suffixes = vorbis_suffixes, .mime_types = vorbis_mime_types }; |