aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist/AsxPlaylistPlugin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist/AsxPlaylistPlugin.cxx')
-rw-r--r--src/playlist/AsxPlaylistPlugin.cxx38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/playlist/AsxPlaylistPlugin.cxx b/src/playlist/AsxPlaylistPlugin.cxx
index 94198b8c3..47983358a 100644
--- a/src/playlist/AsxPlaylistPlugin.cxx
+++ b/src/playlist/AsxPlaylistPlugin.cxx
@@ -23,7 +23,7 @@
#include "MemorySongEnumerator.hxx"
#include "InputStream.hxx"
#include "Song.hxx"
-#include "tag/Tag.hxx"
+#include "tag/TagBuilder.hxx"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
@@ -31,7 +31,6 @@
#include <glib.h>
-#include <assert.h>
#include <string.h>
static constexpr Domain asx_domain("asx");
@@ -58,7 +57,7 @@ struct AsxParser {
* valid if state==ENTRY. TAG_NUM_OF_ITEM_TYPES means there
* is no (known) tag.
*/
- TagType tag;
+ TagType tag_type;
/**
* The current song. It is allocated after the "location"
@@ -66,6 +65,8 @@ struct AsxParser {
*/
Song *song;
+ TagBuilder tag_builder;
+
AsxParser()
:state(ROOT) {}
@@ -96,7 +97,7 @@ asx_start_element(gcc_unused GMarkupParseContext *context,
if (StringEqualsCaseASCII(element_name, "entry")) {
parser->state = AsxParser::ENTRY;
parser->song = Song::NewRemote("asx:");
- parser->tag = TAG_NUM_OF_ITEM_TYPES;
+ parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
}
break;
@@ -107,27 +108,22 @@ asx_start_element(gcc_unused GMarkupParseContext *context,
attribute_values,
"href");
if (href != nullptr) {
- /* create new song object, and copy
- the existing tag over; we cannot
+ /* create new song object; we cannot
replace the existing song's URI,
because that attribute is
immutable */
Song *song = Song::NewRemote(href);
-
- if (parser->song != nullptr) {
- song->tag = parser->song->tag;
- parser->song->tag = nullptr;
+ if (parser->song != nullptr)
parser->song->Free();
- }
parser->song = song;
}
} else if (StringEqualsCaseASCII(element_name, "author"))
/* is that correct? or should it be COMPOSER
or PERFORMER? */
- parser->tag = TAG_ARTIST;
+ parser->tag_type = TAG_ARTIST;
else if (StringEqualsCaseASCII(element_name, "title"))
- parser->tag = TAG_TITLE;
+ parser->tag_type = TAG_TITLE;
break;
}
@@ -146,14 +142,16 @@ asx_end_element(gcc_unused GMarkupParseContext *context,
case AsxParser::ENTRY:
if (StringEqualsCaseASCII(element_name, "entry")) {
- if (strcmp(parser->song->uri, "asx:") != 0)
+ if (strcmp(parser->song->uri, "asx:") != 0) {
+ assert(parser->song->tag == nullptr);
+ parser->song->tag = parser->tag_builder.Commit();
parser->songs.emplace_front(parser->song);
- else
+ } else
parser->song->Free();
parser->state = AsxParser::ROOT;
} else
- parser->tag = TAG_NUM_OF_ITEM_TYPES;
+ parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
break;
}
@@ -171,11 +169,9 @@ asx_text(gcc_unused GMarkupParseContext *context,
break;
case AsxParser::ENTRY:
- if (parser->tag != TAG_NUM_OF_ITEM_TYPES) {
- if (parser->song->tag == nullptr)
- parser->song->tag = new Tag();
- parser->song->tag->AddItem(parser->tag,
- text, text_len);
+ if (parser->tag_type != TAG_NUM_OF_ITEM_TYPES) {
+ parser->tag_builder.AddItem(parser->tag_type,
+ text, text_len);
}
break;