diff options
author | Max Kellermann <max@duempel.org> | 2014-01-14 21:25:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-14 22:33:18 +0100 |
commit | 676d8bb624ef9fb7a8a4983b258d07787efec6b1 (patch) | |
tree | bd8be367773915125a600ebcb4707ece3f1efa86 /src/db/UpnpDatabasePlugin.cxx | |
parent | 4bcaf5d3064ca8846f8652413b2e0deba80aa624 (diff) | |
download | mpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.tar.gz mpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.tar.xz mpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.zip |
db/upnp/Object: add attribute "tag"
Replaces "m_title" and "m_props". More bloat removed.
Diffstat (limited to '')
-rw-r--r-- | src/db/UpnpDatabasePlugin.cxx | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index da8aba22c..257797d1a 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -210,21 +210,7 @@ upnpItemToSong(const UPnPDirObject &dirent, const char *uri) uri = dirent.url.c_str(); Song *s = Song::NewFile(uri, nullptr); - - TagBuilder tag; - - if (dirent.duration > 0) - tag.SetTime(dirent.duration); - - tag.AddItem(TAG_TITLE, dirent.m_title.c_str()); - - for (auto i = upnp_tags; i->name != nullptr; ++i) { - const char *value = dirent.getprop(i->name); - if (value != nullptr) - tag.AddItem(i->type, value); - } - - s->tag = tag.CommitNew(); + s->tag = new Tag(dirent.tag); return s; } @@ -268,27 +254,6 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const } /** - * Retrieve the value for an MPD tag from an object entry. - */ -gcc_pure -static const char * -getTagValue(const UPnPDirObject &dirent, TagType tag) -{ - if (tag == TAG_TITLE) { - if (!dirent.m_title.empty()) - return dirent.m_title.c_str(); - - return nullptr; - } - - const char *name = tag_table_lookup(upnp_tags, tag); - if (name == nullptr) - return nullptr; - - return dirent.getprop(name); -} - -/** * Double-quote a string, adding internal backslash escaping. */ static void @@ -801,7 +766,7 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, dirent.item_class != UPnPDirObject::ItemClass::MUSIC) continue; - const char *value = getTagValue(dirent, tag); + const char *value = dirent.tag.GetValue(tag); if (value != nullptr) { #if defined(__clang__) || GCC_CHECK_VERSION(4,8) values.emplace(value); |