aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-06-15 21:12:55 +0000
committerKalle Wallin <kaw@linux.se>2004-06-15 21:12:55 +0000
commit7857a69fb3c57714a593c71956606e2bae4543c9 (patch)
treeb65f9e1d3bcc50075cdf6926e663308c5c192cf1 /src
parent236077042b696133b4a634be5048faf65b53e6dc (diff)
downloadmpd-7857a69fb3c57714a593c71956606e2bae4543c9.tar.gz
mpd-7857a69fb3c57714a593c71956606e2bae4543c9.tar.xz
mpd-7857a69fb3c57714a593c71956606e2bae4543c9.zip
Disable plchanges - need to redesign the plchanges code
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1504 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/mpdclient.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/mpdclient.c b/src/mpdclient.c
index afc286cc0..c4a88ffe0 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -35,6 +35,7 @@
#define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_DELETE
#define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_MOVE
#define ENABLE_SONG_ID
+#undef ENABLE_PLCHANGES /* something is broken */
#define MPD_ERROR(c) (c==NULL || c->connection==NULL || c->connection->error)
@@ -622,6 +623,7 @@ mpdclient_playlist_update(mpdclient_t *c)
return mpdclient_finish_command(c);
}
+#ifdef ENABLE_PLCHANGES
static gint
compare_songs(gconstpointer a, gconstpointer b)
{
@@ -632,10 +634,10 @@ compare_songs(gconstpointer a, gconstpointer b)
}
/* update playlist (plchanges) */
+
gint
mpdclient_playlist_update_changes(mpdclient_t *c)
{
- gboolean sort = FALSE;
mpd_InfoEntity *entity;
D("mpdclient_playlist_update_changes() [%lld -> %lld]\n",
@@ -663,16 +665,27 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
if( item && item->data)
{
+ GList *old;
+ gint index = g_list_position(c->playlist.list, item);
+
+ /* remove previous song at song->pos */
+ if( song->pos != index &&
+ (old=g_list_nth(c->playlist.list, song->pos)) )
+ {
+ D("Removing item with index %d [%p]\n", index, old);
+ mpd_freeSong((mpd_Song *) old->data);
+ old->data = NULL;
+ c->playlist.list = g_list_delete_link(c->playlist.list, old);
+ }
+
/* Update playlist entry */
- mpd_freeSong((mpd_Song *) item->data);
+ mpd_freeSong((mpd_Song *) item->data);
item->data = song;
if( c->song && c->song->id == song->id )
c->song = song;
- if( !sort && g_list_position(c->playlist.list, item)!=song->pos )
- sort = TRUE;
- D("Changing index %d, num %d [%d] to %s\n",
- g_list_position(c->playlist.list, item),
- song->pos, song->id, get_song_name(song));
+
+ D("Changing index:%d, pos:%d, id:%d => %s\n",
+ index, song->pos, song->id, get_song_name(song));
}
else
{
@@ -699,12 +712,6 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
D("Removed the last playlist entry\n");
}
- if( sort )
- {
- D("Sorting playlist...\n");
- c->playlist.list = g_list_sort(c->playlist.list, compare_songs );
- }
-
c->playlist.id = c->status->playlist;
c->playlist.updated = TRUE;
@@ -712,6 +719,13 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
return 0;
}
+#else
+gint
+mpdclient_playlist_update_changes(mpdclient_t *c)
+{
+ return mpdclient_playlist_update(c);
+}
+#endif
mpd_Song *
playlist_get_song(mpdclient_t *c, gint index)
@@ -727,7 +741,7 @@ playlist_lookup(mpdclient_t *c, gint id)
while( list )
{
mpd_Song *song = (mpd_Song *) list->data;
- if( song->id == id )
+ if( (gint) song->id == id )
return list;
list=list->next;
}