aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 23:19:46 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 23:19:46 +0100
commitbc1e8e01f3e6abaf2c3511ad82535046d6a7b05d (patch)
tree80608056e427a42f31fc3ec7fb43b16c8ab7d803 /src
parentfe8e77e556999fcaeaab1bb4a3555fd72529e2e0 (diff)
downloadmpd-bc1e8e01f3e6abaf2c3511ad82535046d6a7b05d.tar.gz
mpd-bc1e8e01f3e6abaf2c3511ad82535046d6a7b05d.tar.xz
mpd-bc1e8e01f3e6abaf2c3511ad82535046d6a7b05d.zip
DatabaseQueue: pass playlist object
Don't use the global variable "g_playlist".
Diffstat (limited to 'src')
-rw-r--r--src/DatabaseCommands.cxx3
-rw-r--r--src/DatabaseQueue.cxx10
-rw-r--r--src/DatabaseQueue.hxx6
-rw-r--r--src/QueueCommands.cxx3
4 files changed, 14 insertions, 8 deletions
diff --git a/src/DatabaseCommands.cxx b/src/DatabaseCommands.cxx
index 4e636a33f..b52d72f39 100644
--- a/src/DatabaseCommands.cxx
+++ b/src/DatabaseCommands.cxx
@@ -92,7 +92,8 @@ handle_match_add(Client *client, int argc, char *argv[], bool fold_case)
}
GError *error = NULL;
- return findAddIn(client->player_control, "", &filter, &error)
+ return findAddIn(client->playlist, client->player_control,
+ "", &filter, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
}
diff --git a/src/DatabaseQueue.cxx b/src/DatabaseQueue.cxx
index 0b4d2bcb7..f808d25f6 100644
--- a/src/DatabaseQueue.cxx
+++ b/src/DatabaseQueue.cxx
@@ -27,10 +27,11 @@
#include <functional>
static bool
-AddToQueue(struct player_control *pc, song &song, GError **error_r)
+AddToQueue(struct playlist &playlist, struct player_control *pc,
+ song &song, GError **error_r)
{
enum playlist_result result =
- playlist_append_song(&g_playlist, pc, &song, NULL);
+ playlist_append_song(&playlist, pc, &song, NULL);
if (result != PLAYLIST_RESULT_SUCCESS) {
g_set_error(error_r, playlist_quark(), result,
"Playlist error");
@@ -41,7 +42,8 @@ AddToQueue(struct player_control *pc, song &song, GError **error_r)
}
bool
-findAddIn(struct player_control *pc, const char *uri,
+findAddIn(struct playlist &playlist, struct player_control *pc,
+ const char *uri,
const SongFilter *filter, GError **error_r)
{
const Database *db = GetDatabase(error_r);
@@ -51,6 +53,6 @@ findAddIn(struct player_control *pc, const char *uri,
const DatabaseSelection selection(uri, true, filter);
using namespace std::placeholders;
- const auto f = std::bind(AddToQueue, pc, _1, _2);
+ const auto f = std::bind(AddToQueue, playlist, pc, _1, _2);
return db->Visit(selection, f, error_r);
}
diff --git a/src/DatabaseQueue.hxx b/src/DatabaseQueue.hxx
index 21ffe0fb0..50ed7d03a 100644
--- a/src/DatabaseQueue.hxx
+++ b/src/DatabaseQueue.hxx
@@ -24,11 +24,13 @@
#include "gerror.h"
class SongFilter;
+struct playlist;
struct player_control;
-gcc_nonnull(1,2)
+gcc_nonnull(2,3)
bool
-findAddIn(struct player_control *pc, const char *name,
+findAddIn(struct playlist &playlist, struct player_control *pc,
+ const char *name,
const SongFilter *filter, GError **error_r);
#endif
diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx
index 55eab3b46..72649444b 100644
--- a/src/QueueCommands.cxx
+++ b/src/QueueCommands.cxx
@@ -70,7 +70,8 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
}
GError *error = NULL;
- return findAddIn(client->player_control, uri, nullptr, &error)
+ return findAddIn(client->playlist, client->player_control,
+ uri, nullptr, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
}