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/sidplay_decoder_plugin.cxx | |
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/sidplay_decoder_plugin.cxx')
-rw-r--r-- | src/decoder/sidplay_decoder_plugin.cxx | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx index 9aeec8b51..c4ef20496 100644 --- a/src/decoder/sidplay_decoder_plugin.cxx +++ b/src/decoder/sidplay_decoder_plugin.cxx @@ -21,6 +21,7 @@ extern "C" { #include "../decoder_api.h" +#include "tag_handler.h" } #include <errno.h> @@ -336,8 +337,9 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs) } while (cmd != DECODE_COMMAND_STOP); } -static struct tag * -sidplay_tag_dup(const char *path_fs) +static bool +sidplay_scan_file(const char *path_fs, + const struct tag_handler *handler, void *handler_ctx) { int song_num=get_song_num(path_fs); char *path_container=get_container_name(path_fs); @@ -345,10 +347,9 @@ sidplay_tag_dup(const char *path_fs) SidTune tune(path_container, NULL, true); g_free(path_container); if (!tune) - return NULL; + return false; const SidTuneInfo &info = tune.getInfo(); - struct tag *tag = tag_new(); /* title */ const char *title; @@ -360,25 +361,28 @@ sidplay_tag_dup(const char *path_fs) if(info.songs>1) { char *tag_title=g_strdup_printf("%s (%d/%d)", title, song_num, info.songs); - tag_add_item(tag, TAG_TITLE, tag_title); + tag_handler_invoke_tag(handler, handler_ctx, + TAG_TITLE, tag_title); g_free(tag_title); } else - tag_add_item(tag, TAG_TITLE, title); + tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title); /* artist */ if (info.numberOfInfoStrings > 1 && info.infoString[1] != NULL) - tag_add_item(tag, TAG_ARTIST, info.infoString[1]); + tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST, + info.infoString[1]); /* track */ char *track=g_strdup_printf("%d", song_num); - tag_add_item(tag, TAG_TRACK, track); + tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track); g_free(track); /* time */ int song_len=get_song_length(path_fs); - if(song_len!=-1) tag->time=song_len; + if (song_len >= 0) + tag_handler_invoke_duration(handler, handler_ctx, song_len); - return tag; + return true; } static char * @@ -421,7 +425,7 @@ const struct decoder_plugin sidplay_decoder_plugin = { sidplay_finish, NULL, /* stream_decode() */ sidplay_file_decode, - sidplay_tag_dup, + sidplay_scan_file, NULL, /* stream_tag() */ sidplay_container_scan, sidplay_suffixes, |