diff options
author | Max Kellermann <max@duempel.org> | 2014-02-01 01:11:50 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-04 00:57:43 +0100 |
commit | 29072797ca5a397b2878e458db22cb5dcc7dfe4d (patch) | |
tree | 442384db532c0d5d5affa5efa2c415efffe76c0e /src/command | |
parent | db69ceade64c1e1a9c3d7a7c634f8b8b05ce73b9 (diff) | |
download | mpd-29072797ca5a397b2878e458db22cb5dcc7dfe4d.tar.gz mpd-29072797ca5a397b2878e458db22cb5dcc7dfe4d.tar.xz mpd-29072797ca5a397b2878e458db22cb5dcc7dfe4d.zip |
db/DatabasePlaylist: pass Database reference around
Reduce global variable usage, move to frontend code.
Diffstat (limited to '')
-rw-r--r-- | src/command/DatabaseCommands.cxx | 7 | ||||
-rw-r--r-- | src/command/PlaylistCommands.cxx | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 2b871e565..b458b3756 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "DatabaseCommands.hxx" +#include "db/DatabaseGlue.hxx" #include "db/DatabaseQueue.hxx" #include "db/DatabasePlaylist.hxx" #include "db/DatabasePrint.hxx" @@ -119,7 +120,11 @@ handle_searchaddpl(Client &client, int argc, char *argv[]) } Error error; - return search_add_to_playlist("", playlist, &filter, error) + const Database *db = GetDatabase(error); + if (db == nullptr) + return print_error(client, error); + + return search_add_to_playlist(*db, "", playlist, &filter, error) ? CommandResult::OK : print_error(client, error); } diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index 10dfff876..07cc177d6 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "PlaylistCommands.hxx" +#include "db/DatabaseGlue.hxx" #include "db/DatabasePlaylist.hxx" #include "CommandError.hxx" #include "PlaylistPrint.hxx" @@ -192,7 +193,11 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[]) success = spl_append_uri(playlist, loader, uri, error); } else { #ifdef ENABLE_DATABASE - success = search_add_to_playlist(uri, playlist, nullptr, + const Database *db = GetDatabase(error); + if (db == nullptr) + return print_error(client, error); + + success = search_add_to_playlist(*db, uri, playlist, nullptr, error); #else success = false; |