From c2c34f78dd2b63d27bcbd6f21503bf052cad0655 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sat, 5 Jun 2004 01:14:37 +0000 Subject: new command, plchanges, and also add Num: to songinfo of playlistinfo git-svn-id: https://svn.musicpd.org/mpd/trunk@1339 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/playlist.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 18 deletions(-) (limited to 'src/playlist.c') diff --git a/src/playlist.c b/src/playlist.c index c7da3fa38..dd261cfd2 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -36,8 +36,6 @@ #include #include -#define BITS_FOR_VERSION 31 - #define PLAYLIST_COMMENT '#' #define PLAYLIST_STATE_STOP 0 @@ -62,13 +60,15 @@ typedef struct _Playlist { Song ** songs; + /* holds version a song was modified on */ + mpd_uint32 * songMod; int * order; int length; int current; int queued; int repeat; int random; - unsigned long version; + mpd_uint32 version; } Playlist; static Playlist playlist; @@ -87,10 +87,28 @@ static void swapOrder(int a, int b); static int playPlaylistOrderNumber(FILE * fp, int orderNum); static void randomizeOrder(int start, int end); -void incrPlaylistVersion() { - static unsigned long max = ((unsigned long)1<=max) playlist.version = 0; + if(playlist.version>=max) { + int i; + + for(i=0; iutf8url); + if((tag = (playlist.songs[song])->tag)) { + printMpdTag(fp, tag); + } + myfprintf(fp, "Num: %i\n", song); +} + +int playlistChanges(FILE * fp, mpd_uint32 version) { + int i; + + for(i=0; i playlist.version || + playlist.songMod[i] >= version || + playlist.songMod[i] == 0) + { + printPlaylistSongInfo(fp, i); + } + } + + return 0; +} + +int playlistInfo(FILE * fp, int song) { int i; int begin = 0; int end = playlist.length; @@ -380,12 +428,7 @@ int playlistInfo(FILE * fp,int song) { return -1; } - for(i=begin;iutf8url); - if((tag = (playlist.songs[i])->tag)) { - printMpdTag(fp,tag); - } - } + for(i=begin; itype == SONG_TYPE_URL && 0 == strcmp(song->utf8url, songPlayer->utf8url) && @@ -759,6 +808,7 @@ void syncCurrentPlayerDecodeMetadata() { { if(song->tag) freeMpdTag(song->tag); song->tag = mpdTagDup(songPlayer->tag); + playlist.songMod[songNum] = playlist.version; incrPlaylistVersion(); } } @@ -891,11 +941,18 @@ int moveSongInPlaylist(FILE * fp, int from, int to) { tmpSong = playlist.songs[from]; /* move songs to one less in from->to */ - for(i=from;ifrom */ - for(i=from;i>to;i--) playlist.songs[i] = playlist.songs[i-1]; + for(i=from;i>to;i--) { + playlist.songs[i] = playlist.songs[i-1]; + playlist.songMod[i] = playlist.version; + } /* put song at _to_ */ playlist.songs[to] = tmpSong; + playlist.songMod[to] = playlist.version; /* now deal with order */ if(playlist.random) { for(i=0;i