diff options
author | Max Kellermann <max@duempel.org> | 2014-12-01 22:56:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-01 22:56:48 +0100 |
commit | 9e9187342869fd7344d86df59f7856f2f888a14a (patch) | |
tree | a384512d6d04889bf6196fbbdd6d1fbca8fffbb4 /src/decoder/plugins | |
parent | 7363d50a1e284d64f5b347ada036174e4fecaa3c (diff) | |
download | mpd-9e9187342869fd7344d86df59f7856f2f888a14a.tar.gz mpd-9e9187342869fd7344d86df59f7856f2f888a14a.tar.xz mpd-9e9187342869fd7344d86df59f7856f2f888a14a.zip |
decoder/gme: move code to ScanGmeInfo()
Diffstat (limited to '')
-rw-r--r-- | src/decoder/plugins/GmeDecoderPlugin.cxx | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index cc6ce5e5d..df0070482 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -209,6 +209,46 @@ gme_file_decode(Decoder &decoder, Path path_fs) gme_delete(emu); } +static void +ScanGmeInfo(const gme_info_t &info, int song_num, int track_count, + const struct tag_handler *handler, void *handler_ctx) +{ + if (info.length > 0) + tag_handler_invoke_duration(handler, handler_ctx, + SongTime::FromMS(info.length)); + + if (info.song != nullptr) { + if (track_count > 1) { + /* start numbering subtunes from 1 */ + char tag_title[1024]; + snprintf(tag_title, sizeof(tag_title), + "%s (%d/%d)", + info.song, song_num + 1, + track_count); + tag_handler_invoke_tag(handler, handler_ctx, + TAG_TITLE, tag_title); + } else + tag_handler_invoke_tag(handler, handler_ctx, + TAG_TITLE, info.song); + } + + if (info.author != nullptr) + tag_handler_invoke_tag(handler, handler_ctx, + TAG_ARTIST, info.author); + + if (info.game != nullptr) + tag_handler_invoke_tag(handler, handler_ctx, + TAG_ALBUM, info.game); + + if (info.comment != nullptr) + tag_handler_invoke_tag(handler, handler_ctx, + TAG_COMMENT, info.comment); + + if (info.copyright != nullptr) + tag_handler_invoke_tag(handler, handler_ctx, + TAG_DATE, info.copyright); +} + static bool gme_scan_file(Path path_fs, const struct tag_handler *handler, void *handler_ctx) @@ -236,40 +276,8 @@ gme_scan_file(Path path_fs, assert(ti != nullptr); - if (ti->length > 0) - tag_handler_invoke_duration(handler, handler_ctx, - SongTime::FromMS(ti->length)); - - if (ti->song != nullptr) { - if (gme_track_count(emu) > 1) { - /* start numbering subtunes from 1 */ - char tag_title[1024]; - snprintf(tag_title, sizeof(tag_title), - "%s (%d/%d)", - ti->song, song_num + 1, - gme_track_count(emu)); - tag_handler_invoke_tag(handler, handler_ctx, - TAG_TITLE, tag_title); - } else - tag_handler_invoke_tag(handler, handler_ctx, - TAG_TITLE, ti->song); - } - - if (ti->author != nullptr) - tag_handler_invoke_tag(handler, handler_ctx, - TAG_ARTIST, ti->author); - - if (ti->game != nullptr) - tag_handler_invoke_tag(handler, handler_ctx, - TAG_ALBUM, ti->game); - - if (ti->comment != nullptr) - tag_handler_invoke_tag(handler, handler_ctx, - TAG_COMMENT, ti->comment); - - if (ti->copyright != nullptr) - tag_handler_invoke_tag(handler, handler_ctx, - TAG_DATE, ti->copyright); + ScanGmeInfo(*ti, song_num, gme_track_count(emu), + handler, handler_ctx); gme_free_info(ti); gme_delete(emu); |