diff options
author | Max Kellermann <max@duempel.org> | 2014-01-08 23:35:37 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-08 23:35:37 +0100 |
commit | 8f9ba96c59f7d3563e1c3229675ecf7ad16fc334 (patch) | |
tree | a738b3a87920ec38bdacb2ecbe44e3ddd2492df7 /src/command | |
parent | 10406c73b385c7f536cb737d87680e691a80b508 (diff) | |
download | mpd-8f9ba96c59f7d3563e1c3229675ecf7ad16fc334.tar.gz mpd-8f9ba96c59f7d3563e1c3229675ecf7ad16fc334.tar.xz mpd-8f9ba96c59f7d3563e1c3229675ecf7ad16fc334.zip |
SongUpdate: move code to handle_lsinfo()
Don't create a temporary Song object in handle_lsinfo(). Instead,
print all tags while parsing the remote file.
Diffstat (limited to '')
-rw-r--r-- | src/command/OtherCommands.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index e1cbdb618..6ac5ca1c7 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -26,6 +26,8 @@ #include "Song.hxx" #include "SongPrint.hxx" #include "TagPrint.hxx" +#include "TagStream.hxx" +#include "tag/TagHandler.hxx" #include "TimePrint.hxx" #include "Mapper.hxx" #include "DecoderPrint.hxx" @@ -98,6 +100,20 @@ handle_close(gcc_unused Client &client, return CommandResult::FINISH; } +static void +print_tag(TagType type, const char *value, void *ctx) +{ + Client &client = *(Client *)ctx; + + tag_print(client, type, value); +} + +static constexpr tag_handler print_tag_handler = { + nullptr, + print_tag, + nullptr, +}; + CommandResult handle_lsinfo(Client &client, int argc, char *argv[]) { @@ -143,16 +159,12 @@ handle_lsinfo(Client &client, int argc, char *argv[]) return CommandResult::ERROR; } - Song *song = Song::NewRemote(uri); - if (!song->UpdateStream()) { - song->Free(); + if (!tag_stream_scan(uri, print_tag_handler, &client)) { command_error(client, ACK_ERROR_NO_EXIST, "No such file"); return CommandResult::ERROR; } - song_print_info(client, *song); - song->Free(); return CommandResult::OK; } |