aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 20:50:00 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 22:12:33 +0100
commit05c91082e3de0b0078c26ddb9da68fd00da8c90e (patch)
tree7f1ef3988b787ab3e1e07e0147fabf94963495a5 /src
parent7267558ba1cba9338c78b41d11e2eadef6bb515b (diff)
playlist: convert to C++
Diffstat (limited to 'src')
-rw-r--r--src/DatabaseQueue.cxx6
-rw-r--r--src/Main.cxx2
-rw-r--r--src/PlayerCommands.cxx2
-rw-r--r--src/Playlist.cxx (renamed from src/playlist.c)9
-rw-r--r--src/Playlist.hxx (renamed from src/playlist.h)8
-rw-r--r--src/PlaylistCommands.cxx2
-rw-r--r--src/PlaylistControl.cxx (renamed from src/playlist_control.c)10
-rw-r--r--src/PlaylistEdit.cxx3
-rw-r--r--src/PlaylistGlobal.cxx (renamed from src/playlist_global.c)9
-rw-r--r--src/PlaylistInternal.hxx (renamed from src/playlist_internal.h)8
-rw-r--r--src/PlaylistPrint.cxx2
-rw-r--r--src/PlaylistQueue.cxx2
-rw-r--r--src/PlaylistSave.cxx4
-rw-r--r--src/PlaylistState.cxx4
-rw-r--r--src/Queue.cxx (renamed from src/queue.c)30
-rw-r--r--src/Queue.hxx (renamed from src/queue.h)6
-rw-r--r--src/QueueCommands.cxx2
-rw-r--r--src/QueuePrint.cxx4
-rw-r--r--src/QueueSave.cxx2
-rw-r--r--src/StateFile.cxx2
-rw-r--r--src/UpdateGlue.cxx4
-rw-r--r--src/UpdateRemove.cxx2
-rw-r--r--src/replay_gain_config.c4
23 files changed, 66 insertions, 61 deletions
diff --git a/src/DatabaseQueue.cxx b/src/DatabaseQueue.cxx
index 325748d0..0b4d2bcb 100644
--- a/src/DatabaseQueue.cxx
+++ b/src/DatabaseQueue.cxx
@@ -20,13 +20,9 @@
#include "config.h"
#include "DatabaseQueue.hxx"
#include "DatabaseSelection.hxx"
-
-extern "C" {
-#include "playlist.h"
-}
-
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
+#include "Playlist.hxx"
#include <functional>
diff --git a/src/Main.cxx b/src/Main.cxx
index 2da1ca69..3340bf3d 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "Main.hxx"
#include "CommandLine.hxx"
+#include "Playlist.hxx"
#include "PlaylistFile.hxx"
#include "UpdateGlue.hxx"
#include "MusicChunk.hxx"
@@ -38,7 +39,6 @@ extern "C" {
#include "daemon.h"
#include "io_thread.h"
#include "idle.h"
-#include "playlist.h"
#include "conf.h"
#include "path.h"
#include "player_control.h"
diff --git a/src/PlayerCommands.cxx b/src/PlayerCommands.cxx
index e4b5c145..55bd83a1 100644
--- a/src/PlayerCommands.cxx
+++ b/src/PlayerCommands.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "PlayerCommands.hxx"
#include "CommandError.hxx"
+#include "Playlist.hxx"
#include "PlaylistPrint.hxx"
#include "UpdateGlue.hxx"
#include "ClientInternal.hxx"
@@ -28,7 +29,6 @@
extern "C" {
#include "player_control.h"
-#include "playlist.h"
#include "volume.h"
#include "replay_gain_config.h"
}
diff --git a/src/playlist.c b/src/Playlist.cxx
index 2532d9d4..de2daf14 100644
--- a/src/playlist.c
+++ b/src/Playlist.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,11 +18,14 @@
*/
#include "config.h"
-#include "playlist_internal.h"
-#include "player_control.h"
+#include "PlaylistInternal.hxx"
#include "song.h"
+
+extern "C" {
+#include "player_control.h"
#include "conf.h"
#include "idle.h"
+}
#include <glib.h>
diff --git a/src/playlist.h b/src/Playlist.hxx
index a21bdf24..3bbb112b 100644
--- a/src/playlist.h
+++ b/src/Playlist.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,10 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_H
-#define MPD_PLAYLIST_H
+#ifndef MPD_PLAYLIST_HXX
+#define MPD_PLAYLIST_HXX
-#include "queue.h"
+#include "Queue.hxx"
#include "playlist_error.h"
#include <stdbool.h>
diff --git a/src/PlaylistCommands.cxx b/src/PlaylistCommands.cxx
index d2defff3..d8a9b5fc 100644
--- a/src/PlaylistCommands.cxx
+++ b/src/PlaylistCommands.cxx
@@ -31,9 +31,9 @@
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
+#include "Playlist.hxx"
extern "C" {
-#include "playlist.h"
#include "uri.h"
}
diff --git a/src/playlist_control.c b/src/PlaylistControl.cxx
index 57cc428f..464b25cf 100644
--- a/src/playlist_control.c
+++ b/src/PlaylistControl.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,10 +23,12 @@
*/
#include "config.h"
-#include "playlist_internal.h"
-#include "player_control.h"
+#include "PlaylistInternal.hxx"
#include "song.h"
-#include "idle.h"
+
+extern "C" {
+#include "player_control.h"
+}
#include <glib.h>
diff --git a/src/PlaylistEdit.cxx b/src/PlaylistEdit.cxx
index d44de058..baf48342 100644
--- a/src/PlaylistEdit.cxx
+++ b/src/PlaylistEdit.cxx
@@ -24,8 +24,9 @@
*/
#include "config.h"
+#include "PlaylistInternal.hxx"
+
extern "C" {
-#include "playlist_internal.h"
#include "player_control.h"
#include "uri.h"
#include "song.h"
diff --git a/src/playlist_global.c b/src/PlaylistGlobal.cxx
index e66febce..91c571b6 100644
--- a/src/playlist_global.c
+++ b/src/PlaylistGlobal.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,10 +23,13 @@
*/
#include "config.h"
-#include "playlist.h"
-#include "event_pipe.h"
+#include "Playlist.hxx"
#include "Main.hxx"
+extern "C" {
+#include "event_pipe.h"
+}
+
struct playlist g_playlist;
static void
diff --git a/src/playlist_internal.h b/src/PlaylistInternal.hxx
index 81b17517..f0cad8e6 100644
--- a/src/playlist_internal.h
+++ b/src/PlaylistInternal.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,10 +22,10 @@
*
*/
-#ifndef PLAYLIST_INTERNAL_H
-#define PLAYLIST_INTERNAL_H
+#ifndef MPD_PLAYLIST_INTERNAL_HXX
+#define MPD_PLAYLIST_INTERNAL_HXX
-#include "playlist.h"
+#include "Playlist.hxx"
struct player_control;
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index de17ac2c..cbbd71bb 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -22,6 +22,7 @@
#include "PlaylistFile.hxx"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
+#include "Playlist.hxx"
#include "QueuePrint.hxx"
#include "SongPrint.hxx"
#include "DatabaseGlue.hxx"
@@ -31,7 +32,6 @@
extern "C" {
#include "playlist_list.h"
#include "playlist_plugin.h"
-#include "playlist.h"
#include "song.h"
#include "input_stream.h"
}
diff --git a/src/PlaylistQueue.cxx b/src/PlaylistQueue.cxx
index ad973944..e7572031 100644
--- a/src/PlaylistQueue.cxx
+++ b/src/PlaylistQueue.cxx
@@ -22,9 +22,9 @@
#include "playlist_plugin.h"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
+#include "Playlist.hxx"
extern "C" {
-#include "playlist.h"
#include "song.h"
#include "input_stream.h"
}
diff --git a/src/PlaylistSave.cxx b/src/PlaylistSave.cxx
index 722ae9c8..7b88a843 100644
--- a/src/PlaylistSave.cxx
+++ b/src/PlaylistSave.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,11 +20,11 @@
#include "config.h"
#include "PlaylistSave.hxx"
#include "PlaylistFile.hxx"
+#include "Playlist.hxx"
#include "song.h"
#include "Mapper.hxx"
extern "C" {
-#include "playlist.h"
#include "path.h"
#include "uri.h"
#include "idle.h"
diff --git a/src/PlaylistState.cxx b/src/PlaylistState.cxx
index 1bb18250..92aa6294 100644
--- a/src/PlaylistState.cxx
+++ b/src/PlaylistState.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -24,11 +24,11 @@
#include "config.h"
#include "PlaylistState.hxx"
+#include "Playlist.hxx"
#include "QueueSave.hxx"
#include "TextFile.hxx"
extern "C" {
-#include "playlist.h"
#include "player_control.h"
#include "conf.h"
}
diff --git a/src/queue.c b/src/Queue.cxx
index 098cbcce..485ffb1c 100644
--- a/src/queue.c
+++ b/src/Queue.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include "queue.h"
+#include "Queue.hxx"
#include "song.h"
#include <stdlib.h>
@@ -102,12 +102,11 @@ queue_append(struct queue *queue, struct song *song, uint8_t priority)
assert(!queue_is_full(queue));
- queue->items[queue->length] = (struct queue_item){
- .song = song_dup_detached(song),
- .id = id,
- .version = queue->version,
- .priority = priority,
- };
+ auto &item = queue->items[queue->length];
+ item.song = song_dup_detached(song);
+ item.id = id;
+ item.version = queue->version;
+ item.priority = priority;
queue->order[queue->length] = queue->length;
queue->id_to_position[id] = queue->length;
@@ -313,10 +312,11 @@ queue_init(struct queue *queue, unsigned max_length)
queue->consume = false;
queue->items = g_new(struct queue_item, max_length);
- queue->order = g_malloc(sizeof(queue->order[0]) *
- max_length);
- queue->id_to_position = g_malloc(sizeof(queue->id_to_position[0]) *
- max_length * QUEUE_HASH_MULT);
+ queue->order = (unsigned *)
+ g_malloc(sizeof(queue->order[0]) * max_length);
+ queue->id_to_position = (int *)
+ g_malloc(sizeof(queue->id_to_position[0]) *
+ max_length * QUEUE_HASH_MULT);
for (unsigned i = 0; i < max_length * QUEUE_HASH_MULT; ++i)
queue->id_to_position[i] = -1;
@@ -355,9 +355,9 @@ static gint
queue_item_compare_order_priority(gconstpointer av, gconstpointer bv,
gpointer user_data)
{
- const struct queue *queue = user_data;
- const unsigned *const ap = av;
- const unsigned *const bp = bv;
+ const struct queue *queue = (const struct queue *)user_data;
+ const unsigned *const ap = (const unsigned *)av;
+ const unsigned *const bp = (const unsigned *)bv;
assert(ap >= queue->order && ap < queue->order + queue->length);
assert(bp >= queue->order && bp < queue->order + queue->length);
uint8_t a = queue->items[*ap].priority;
diff --git a/src/queue.h b/src/Queue.hxx
index e4bfcdff..4c6d5ea1 100644
--- a/src/queue.h
+++ b/src/Queue.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef QUEUE_H
-#define QUEUE_H
+#ifndef MPD_QUEUE_HXX
+#define MPD_QUEUE_HXX
#include <glib.h>
diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx
index 8a13075a..af3ad60c 100644
--- a/src/QueueCommands.cxx
+++ b/src/QueueCommands.cxx
@@ -22,6 +22,7 @@
#include "CommandError.hxx"
#include "DatabaseQueue.hxx"
#include "SongFilter.hxx"
+#include "Playlist.hxx"
#include "PlaylistPrint.hxx"
#include "ClientFile.hxx"
#include "ClientInternal.hxx"
@@ -30,7 +31,6 @@
#include "ls.hxx"
extern "C" {
-#include "playlist.h"
#include "uri.h"
}
diff --git a/src/QueuePrint.cxx b/src/QueuePrint.cxx
index bd49f92e..289ae26b 100644
--- a/src/QueuePrint.cxx
+++ b/src/QueuePrint.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,13 @@
#include "config.h"
#include "QueuePrint.hxx"
+#include "Queue.hxx"
#include "SongFilter.hxx"
#include "SongPrint.hxx"
#include "Mapper.hxx"
#include "Client.hxx"
extern "C" {
-#include "queue.h"
#include "song.h"
}
diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx
index 6ba48f33..a667bc85 100644
--- a/src/QueueSave.cxx
+++ b/src/QueueSave.cxx
@@ -19,6 +19,7 @@
#include "config.h"
#include "QueueSave.hxx"
+#include "Playlist.hxx"
#include "song.h"
#include "SongSave.hxx"
#include "DatabasePlugin.hxx"
@@ -26,7 +27,6 @@
#include "TextFile.hxx"
extern "C" {
-#include "queue.h"
#include "uri.h"
}
diff --git a/src/StateFile.cxx b/src/StateFile.cxx
index cd344eb0..db663502 100644
--- a/src/StateFile.cxx
+++ b/src/StateFile.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "StateFile.hxx"
#include "OutputState.hxx"
-#include "playlist.h"
+#include "Playlist.hxx"
#include "PlaylistState.hxx"
#include "TextFile.hxx"
diff --git a/src/UpdateGlue.cxx b/src/UpdateGlue.cxx
index f5664893..cb1600d4 100644
--- a/src/UpdateGlue.cxx
+++ b/src/UpdateGlue.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -24,9 +24,9 @@
#include "UpdateRemove.hxx"
#include "Mapper.hxx"
#include "DatabaseSimple.hxx"
+#include "Playlist.hxx"
extern "C" {
-#include "playlist.h"
#include "event_pipe.h"
#include "idle.h"
#include "stats.h"
diff --git a/src/UpdateRemove.cxx b/src/UpdateRemove.cxx
index c88eec42..814c803b 100644
--- a/src/UpdateRemove.cxx
+++ b/src/UpdateRemove.cxx
@@ -19,10 +19,10 @@
#include "config.h" /* must be first for large file support */
#include "UpdateRemove.hxx"
+#include "Playlist.hxx"
extern "C" {
#include "event_pipe.h"
-#include "playlist.h"
}
#include "song.h"
diff --git a/src/replay_gain_config.c b/src/replay_gain_config.c
index 2181387b..3988e497 100644
--- a/src/replay_gain_config.c
+++ b/src/replay_gain_config.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "config.h"
#include "replay_gain_config.h"
-#include "playlist.h"
+#include "Playlist.hxx"
#include "conf.h"
#include "idle.h"
#include "mpd_error.h"