diff options
author | Max Kellermann <max@duempel.org> | 2014-01-18 16:13:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-18 16:13:33 +0100 |
commit | 0c2485e86c280c69752a8fa6101e8d77ee4b9b25 (patch) | |
tree | 309e0f3649518c087ff35c233ec1db3d71d9e5e7 | |
parent | 7d696a7063c7510485f2fbf315731212d28e49e0 (diff) | |
download | mpd-0c2485e86c280c69752a8fa6101e8d77ee4b9b25.tar.gz mpd-0c2485e86c280c69752a8fa6101e8d77ee4b9b25.tar.xz mpd-0c2485e86c280c69752a8fa6101e8d77ee4b9b25.zip |
db/upnp: use getServer() in Visit()
Reduce bloat.
-rw-r--r-- | src/db/UpnpDatabasePlugin.cxx | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index 98c8a5ff3..8d107a74e 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -678,12 +678,12 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, VisitPlaylist visit_playlist, Error &error) const { - std::vector<ContentDirectoryService> servers; - if (!m_superdir->getDirServices(servers, error)) - return false; - auto vpath = stringToTokens(selection.uri, "/", true); if (vpath.empty()) { + std::vector<ContentDirectoryService> servers; + if (!m_superdir->getDirServices(servers, error)) + return false; + if (!selection.recursive) { // If the path is empty and recursive is not set, synthetize a // pseudo-directory from the list of servers. @@ -709,19 +709,11 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, std::string servername(vpath[0]); vpath.erase(vpath.begin()); - ContentDirectoryService *server = 0; - for (auto& dir : servers) { - if (!servername.compare(dir.getFriendlyName())) { - server = &dir; - break; - } - } - if (server == 0) { - FormatDebug(db_domain, "UpnpDatabase::Visit: server %s not found\n", - vpath[0].c_str()); - return true; - } - return VisitServer(*server, vpath, selection, + ContentDirectoryService server; + if (!m_superdir->getServer(servername.c_str(), server, error)) + return false; + + return VisitServer(server, vpath, selection, visit_directory, visit_song, visit_playlist, error); } |