aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQball Cow <qball@qballcow.nl>2007-08-19 19:38:47 +0000
committerQball Cow <qball@qballcow.nl>2007-08-19 19:38:47 +0000
commit6dc71a392896d8e1ad1dcec8dc445ab633de7089 (patch)
tree83886bfd3b2272f1c6bf5db5229b5fb437c7c5b6 /src
parent609263594c2e1aae7565f3d00cd509688e4566bd (diff)
downloadmpd-6dc71a392896d8e1ad1dcec8dc445ab633de7089.tar.gz
mpd-6dc71a392896d8e1ad1dcec8dc445ab633de7089.tar.xz
mpd-6dc71a392896d8e1ad1dcec8dc445ab633de7089.zip
Custom patch to add a playlist versioning number, needs testing
git-svn-id: https://svn.musicpd.org/mpd/branches/q-mpd@6765 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/command.c5
-rw-r--r--src/storedPlaylist.c37
-rw-r--r--src/storedPlaylist.h2
3 files changed, 43 insertions, 1 deletions
diff --git a/src/command.c b/src/command.c
index 83a8d3a2d..85f2616af 100644
--- a/src/command.c
+++ b/src/command.c
@@ -110,7 +110,8 @@
#define COMMAND_STATUS_REPEAT "repeat"
#define COMMAND_STATUS_RANDOM "random"
#define COMMAND_STATUS_PLAYLIST "playlist"
-#define COMMAND_STATUS_PLAYLIST_QUEUE "playlistqueue"
+#define COMMAND_STATUS_PLAYLIST_QUEUE "playlistqueue"
+#define COMMAND_STATUS_STORED_PLAYLIST "storedplaylist"
#define COMMAND_STATUS_PLAYLIST_LENGTH "playlistlength"
#define COMMAND_STATUS_SONG "song"
#define COMMAND_STATUS_SONGID "songid"
@@ -284,6 +285,8 @@ static int commandStatus(int fd, int *permission, int argc, char *argv[])
getPlaylistVersion());
fdprintf(fd, "%s: %li\n", COMMAND_STATUS_PLAYLIST_QUEUE,
getPlaylistQueueVersion());
+ fdprintf(fd, "%s: %li\n", COMMAND_STATUS_STORED_PLAYLIST,
+ getStoredPlaylistVersion());
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_PLAYLIST_LENGTH,
getPlaylistLength());
fdprintf(fd, "%s: %i\n", COMMAND_STATUS_CROSSFADE,
diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c
index 322cb1b5b..e0ed0e745 100644
--- a/src/storedPlaylist.c
+++ b/src/storedPlaylist.c
@@ -28,6 +28,19 @@
#include <string.h>
#include <errno.h>
+static mpd_uint32 storedplaylistversion =0;
+static void incrStoredPlaylistVersion(void)
+{
+ static unsigned long max = ((mpd_uint32) 1 << 31) - 1;
+ storedplaylistversion++;
+ if (storedplaylistversion >= max)
+ storedplaylistversion = 1;
+}
+
+unsigned long getStoredPlaylistVersion(void)
+{
+ return storedplaylistversion;
+}
static char *utf8pathToFsPathInStoredPlaylist(const char *utf8path, int fd)
{
@@ -101,6 +114,7 @@ static ListNode *nodeOfStoredPlaylist(StoredPlaylist *sp, int index)
static void appendSongToStoredPlaylist(StoredPlaylist *sp, Song *song)
{
insertInListWithoutKey(sp->list, xstrdup(getSongUrl(song)));
+ incrStoredPlaylistVersion();
}
StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisting)
@@ -130,6 +144,9 @@ StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisti
if (filename)
sp->fspath = xstrdup(filename);
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
+
return sp;
}
@@ -291,6 +308,8 @@ static int moveSongInStoredPlaylist(int fd, StoredPlaylist *sp, int src, int des
destNode->nextNode = srcNode;
}
}
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
return 0;
}
@@ -315,6 +334,10 @@ int moveSongInStoredPlaylistByPath(int fd, const char *utf8path, int src, int de
}
freeStoredPlaylist(sp);
+
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
+
return 0;
}
@@ -343,6 +366,9 @@ int removeAllFromStoredPlaylistByPath(int fd, const char *utf8path)
}
while (fclose(file) != 0 && errno == EINTR);
+
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
return 0;
}
@@ -357,6 +383,8 @@ static int removeOneSongFromStoredPlaylist(int fd, StoredPlaylist *sp, int pos)
deleteNodeFromList(sp->list, node);
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
return 0;
}
@@ -380,6 +408,9 @@ int removeOneSongFromStoredPlaylistByPath(int fd, const char *utf8path, int pos)
}
freeStoredPlaylist(sp);
+
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
return 0;
}
@@ -444,6 +475,8 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
fprintf(file, "%s\n", s);
while (fclose(file) != 0 && errno == EINTR);
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
return 0;
}
@@ -452,6 +485,8 @@ void appendPlaylistToStoredPlaylist(StoredPlaylist *sp, Playlist *playlist)
int i;
for (i = 0; i < playlist->length; i++)
appendSongToStoredPlaylist(sp, playlist->songs[i]);
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
}
int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
@@ -493,6 +528,8 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
goto out;
}
+ /* Increase stored playlist version id*/
+ incrStoredPlaylistVersion();
out:
free(from);
free(to);
diff --git a/src/storedPlaylist.h b/src/storedPlaylist.h
index 1c30e814a..55387742f 100644
--- a/src/storedPlaylist.h
+++ b/src/storedPlaylist.h
@@ -45,4 +45,6 @@ void appendPlaylistToStoredPlaylist(StoredPlaylist *sp, Playlist *playlist);
int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to);
+unsigned long getStoredPlaylistVersion(void);
+
#endif