From f031eb1ef22373f94838b7e3357f2913ced6db71 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Jan 2014 10:17:30 +0100 Subject: db/upnp/Directory: parse duration Don't put all attributes to the attributes map; parse the "duration" attribute as soon as we receive it, and store it in an integer attribute. This reduces bloat. --- src/db/UpnpDatabasePlugin.cxx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/db/UpnpDatabasePlugin.cxx') diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index be035bb00..5228d8b60 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -229,16 +229,6 @@ titleToPathElt(const std::string &in) return out; } -gcc_pure -static int -upnpDurationToSeconds(const std::string &duration) -{ - const auto v = stringToTokens(duration, ":"); - if (v.size() != 3) - return 0; - return atoi(v[0].c_str())*3600 + atoi(v[1].c_str())*60 + atoi(v[2].c_str()); -} - // If uri is empty, we use the object's url instead. This happens // when the target of a Visit() is a song, which only happens when // "add"ing AFAIK. Visit() calls us with a null uri so that the url @@ -253,9 +243,8 @@ upnpItemToSong(const UPnPDirObject &dirent, const char *uri) TagBuilder tag; - const char *duration = dirent.getprop("duration"); - if (duration != nullptr) - tag.SetTime(upnpDurationToSeconds(duration)); + if (dirent.duration > 0) + tag.SetTime(dirent.duration); tag.AddItem(TAG_TITLE, titleToPathElt(dirent.m_title).c_str()); -- cgit v1.2.3