diff options
-rw-r--r-- | src/Song.hxx | 1 | ||||
-rw-r--r-- | src/SongUpdate.cxx | 14 | ||||
-rw-r--r-- | src/TagPrint.cxx | 6 | ||||
-rw-r--r-- | src/TagPrint.hxx | 7 | ||||
-rw-r--r-- | src/command/OtherCommands.cxx | 22 |
5 files changed, 30 insertions, 20 deletions
diff --git a/src/Song.hxx b/src/Song.hxx index b9f529702..21e158560 100644 --- a/src/Song.hxx +++ b/src/Song.hxx @@ -130,7 +130,6 @@ struct Song { bool UpdateFile(); bool UpdateFileInArchive(); - bool UpdateStream(); /** * Returns the URI of the song in UTF-8 encoding, including its diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index fe78e1e0f..953c23961 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -132,17 +132,3 @@ Song::UpdateFileInArchive() tag = tag_builder.CommitNew(); return true; } - -bool -Song::UpdateStream() -{ - assert(!IsFile()); - - TagBuilder tag_builder; - if (!tag_stream_scan(uri, full_tag_handler, &tag_builder)) - return false; - - delete tag; - tag = tag_builder.CommitNew(); - return true; -} diff --git a/src/TagPrint.cxx b/src/TagPrint.cxx index 1191bd37c..0b096fdf7 100644 --- a/src/TagPrint.cxx +++ b/src/TagPrint.cxx @@ -35,6 +35,12 @@ void tag_print_types(Client &client) } } +void +tag_print(Client &client, TagType type, const char *value) +{ + client_printf(client, "%s: %s\n", tag_item_names[type], value); +} + void tag_print(Client &client, const Tag &tag) { if (tag.time >= 0) diff --git a/src/TagPrint.hxx b/src/TagPrint.hxx index ccc0c9aa4..48ddc28ec 100644 --- a/src/TagPrint.hxx +++ b/src/TagPrint.hxx @@ -20,12 +20,19 @@ #ifndef MPD_TAG_PRINT_HXX #define MPD_TAG_PRINT_HXX +#include <stdint.h> + +enum TagType : uint8_t; + struct Tag; class Client; void tag_print_types(Client &client); void +tag_print(Client &client, TagType type, const char *value); + +void tag_print(Client &client, const Tag &tag); #endif 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; } |