summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2360770)
raw | patch | inline | side by side (parent: 2360770)
author | Kalle Wallin <kaw@linux.se> | |
Tue, 15 Jun 2004 21:12:55 +0000 (21:12 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Tue, 15 Jun 2004 21:12:55 +0000 (21:12 +0000) |
src/mpdclient.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index afc286cc0b03f033bd40578707c8af5f4a0af921..c4a88ffe0b548e5385dac792559f908a950a64c0 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#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)
return mpdclient_finish_command(c);
}
+#ifdef ENABLE_PLCHANGES
static gint
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",
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
{
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;
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)
while( list )
{
mpd_Song *song = (mpd_Song *) list->data;
- if( song->id == id )
+ if( (gint) song->id == id )
return list;
list=list->next;
}