summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4ac153)
raw | patch | inline | side by side (parent: a4ac153)
author | Max Kellermann <max@duempel.org> | |
Sun, 18 Oct 2009 00:20:11 +0000 (02:20 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sun, 18 Oct 2009 00:20:11 +0000 (02:20 +0200) |
src/playlist.c | patch | blob | history | |
src/playlist.h | patch | blob | history |
diff --git a/src/playlist.c b/src/playlist.c
index dfe9cad57b32b0a763eb50cc4aa233312565560c..2ce7ae2b697d9e9f3d277192aafe8d3c5c078377 100644 (file)
--- a/src/playlist.c
+++ b/src/playlist.c
return playlist_get(playlist, idx);
}
+void
+playlist_move(struct mpdclient_playlist *playlist,
+ unsigned dest, unsigned src)
+{
+ struct mpd_song *song;
+
+ assert(playlist != NULL);
+ assert(src < playlist_length(playlist));
+ assert(dest < playlist_length(playlist));
+ assert(src != dest);
+
+ song = playlist_get(playlist, src);
+
+ if (src < dest) {
+ memmove(&playlist->list->pdata[src],
+ &playlist->list->pdata[src + 1],
+ sizeof(playlist->list->pdata[0]) * (dest - src));
+ playlist->list->pdata[dest] = song;
+ } else {
+ memmove(&playlist->list->pdata[dest + 1],
+ &playlist->list->pdata[dest],
+ sizeof(playlist->list->pdata[0]) * (src - dest));
+ playlist->list->pdata[dest] = song;
+ }
+}
+
const struct mpd_song *
playlist_lookup_song(const struct mpdclient_playlist *playlist, unsigned id)
{
diff --git a/src/playlist.h b/src/playlist.h
index 45046880869d3c545f42158c767c8dd32b3f8ad9..8768b9e5a5bcd366cd9438cb591e80d30f7a515a 100644 (file)
--- a/src/playlist.h
+++ b/src/playlist.h
g_ptr_array_index(playlist->list, idx2) = song1;
}
+void
+playlist_move(struct mpdclient_playlist *playlist,
+ unsigned dest, unsigned src);
+
const struct mpd_song *
playlist_lookup_song(const struct mpdclient_playlist *playlist, unsigned id);