From 5fa0da2d9b0edf78097a0d29b1bde3c260a36af4 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 29 Sep 2013 19:35:36 +0200 Subject: added new APIs for saving current playlist --- playlist.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'playlist.c') diff --git a/playlist.c b/playlist.c index f59d8251..9b78551f 100644 --- a/playlist.c +++ b/playlist.c @@ -414,7 +414,7 @@ plt_add (int before, const char *title) { plt_gen_conf (); if (!plt_loading) { - pl_save_n (before); + plt_save_n (before); conf_save (); messagepump_push (DB_EV_PLAYLISTSWITCHED, 0, 0, 0); } @@ -464,7 +464,7 @@ plt_remove (int plt) { UNLOCK; plt_gen_conf (); conf_save (); - pl_save_n (0); + plt_save_n (0); messagepump_push (DB_EV_PLAYLISTSWITCHED, 0, 0, 0); return; } @@ -2073,7 +2073,7 @@ save_fail: } int -pl_save_n (int n) { +plt_save_n (int n) { char path[PATH_MAX]; if (snprintf (path, sizeof (path), "%s/playlists", dbconfdir) > sizeof (path)) { fprintf (stderr, "error: failed to make path string for playlists folder\n"); @@ -2103,7 +2103,7 @@ pl_save_n (int n) { int pl_save_current (void) { - return pl_save_n (plt_get_curr_idx ()); + return plt_save_n (plt_get_curr_idx ()); } int @@ -3890,3 +3890,23 @@ pl_ensure_lock (void) { assert(0); #endif } + +int +plt_get_idx (playlist_t *plt) { + int i; + playlist_t *p; + for (i = 0, p = playlists_head; p && p != plt; i++, p = p->next); + if (p == 0) { + return -1; + } + return i; +} + +int +plt_save_config (playlist_t *plt) { + int i = plt_get_idx (plt); + if (i == -1) { + return -1; + } + return plt_save_n (i); +} -- cgit v1.2.3