---
 src/command/FileCommands.cxx                       |  1 +
 src/command/OtherCommands.cxx                      |  1 +
 src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx |  1 +
 src/tag/TagHandler.cxx                             | 10 ++++++++++
 src/tag/TagHandler.hxx                             | 14 ++++++++++++++
 5 files changed, 27 insertions(+)

diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx
index 7673c0a..c092d3e 100644
--- a/src/command/FileCommands.cxx
+++ b/src/command/FileCommands.cxx
@@ -167,6 +167,7 @@ static constexpr tag_handler print_comment_handler = {
        nullptr,
        nullptr,
        print_pair,
+       nullptr,
 };
 
 static CommandResult
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx
index 9ca7567..3d072db 100644
--- a/src/command/OtherCommands.cxx
+++ b/src/command/OtherCommands.cxx
@@ -148,6 +148,7 @@ static constexpr tag_handler print_tag_handler = {
        nullptr,
        print_tag,
        nullptr,
+       nullptr,
 };
 
 CommandResult
diff --git a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx 
b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
index 29b15b1..7c3f5b5 100644
--- a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
+++ b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
@@ -86,6 +86,7 @@ static const struct tag_handler embcue_tag_handler = {
        nullptr,
        nullptr,
        embcue_tag_pair,
+       nullptr,
 };
 
 static SongEnumerator *
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx
index 9bbaae3..0541f9f 100644
--- a/src/tag/TagHandler.cxx
+++ b/src/tag/TagHandler.cxx
@@ -38,10 +38,19 @@ add_tag_tag(TagType type, const char *value, void *ctx)
        tag.AddItem(type, value);
 }
 
+static bool
+tag_is_empty(void *ctx)
+{
+       TagBuilder &tag = *(TagBuilder *)ctx;
+
+       return tag.IsEmpty();
+}
+
 const struct tag_handler add_tag_handler = {
        add_tag_duration,
        add_tag_tag,
        nullptr,
+       tag_is_empty,
 };
 
 static void
@@ -57,5 +66,6 @@ const struct tag_handler full_tag_handler = {
        add_tag_duration,
        add_tag_tag,
        full_tag_pair,
+       tag_is_empty,
 };
 
diff --git a/src/tag/TagHandler.hxx b/src/tag/TagHandler.hxx
index e87c299..b3121ec 100644
--- a/src/tag/TagHandler.hxx
+++ b/src/tag/TagHandler.hxx
@@ -50,6 +50,12 @@ struct tag_handler {
         * representation of tags.
         */
        void (*pair)(const char *key, const char *value, void *ctx);
+
+       /**
+        * Returns true if no tags has been read. The ignores the "duration"
+        * attribute.
+        */
+       bool (*is_empty)(void *ctx);
 };
 
 static inline void
@@ -86,6 +92,14 @@ tag_handler_invoke_pair(const struct tag_handler *handler, 
void *ctx,
                handler->pair(name, value, ctx);
 }
 
+static inline bool
+tag_handler_invoke_is_empty(const struct tag_handler *handler, void *ctx)
+{
+       assert(handler != nullptr);
+
+       return handler->is_empty != nullptr && handler->is_empty(ctx);
+}
+
 /**
  * This #tag_handler implementation adds tag values to a #TagBuilder object
  * (casted from the context pointer).
-- 
2.1.4

_______________________________________________
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to