diff options
author | Max Kellermann <max@duempel.org> | 2014-01-21 22:43:04 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-21 22:43:04 +0100 |
commit | dc5ef9ad0103b19546ca22adff094184380e9f2e (patch) | |
tree | f769b89c51f1cfde7de0b4f5eb9c6d346b21e2fd /src | |
parent | 7471f65d952336ec18fba4c057b864615a5ce89b (diff) | |
download | mpd-dc5ef9ad0103b19546ca22adff094184380e9f2e.tar.gz mpd-dc5ef9ad0103b19546ca22adff094184380e9f2e.tar.xz mpd-dc5ef9ad0103b19546ca22adff094184380e9f2e.zip |
db/upnp: simplify GetSong()
Diffstat (limited to 'src')
-rw-r--r-- | src/db/UpnpDatabasePlugin.cxx | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index c778ca34e..5ce09e31e 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -219,31 +219,29 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const const LightSong * UpnpDatabase::GetSong(const char *uri, Error &error) const { - UpnpSong *song = nullptr; auto vpath = stringToTokens(uri, "/", true); - if (vpath.size() >= 2) { - ContentDirectoryService server; - if (!m_superdir->getServer(vpath[0].c_str(), server, error)) - return nullptr; + if (vpath.size() < 2) { + error.Format(db_domain, DB_NOT_FOUND, "No such song: %s", uri); + return nullptr; + } - vpath.erase(vpath.begin()); - UPnPDirObject dirent; - if (vpath[0].compare(rootid)) { - std::string objid; - if (!Namei(server, vpath, objid, dirent, error)) - return nullptr; - } else { - if (!ReadNode(server, vpath.back().c_str(), dirent, - error)) - return nullptr; - } + ContentDirectoryService server; + if (!m_superdir->getServer(vpath[0].c_str(), server, error)) + return nullptr; - song = new UpnpSong(std::move(dirent), uri); + vpath.erase(vpath.begin()); + UPnPDirObject dirent; + if (vpath[0].compare(rootid)) { + std::string objid; + if (!Namei(server, vpath, objid, dirent, error)) + return nullptr; + } else { + if (!ReadNode(server, vpath.back().c_str(), dirent, + error)) + return nullptr; } - if (song == nullptr) - error.Format(db_domain, DB_NOT_FOUND, "No such song: %s", uri); - return song; + return new UpnpSong(std::move(dirent), uri); } /** |