diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-09-29 19:35:36 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-09-29 19:35:36 +0200 |
commit | 5fa0da2d9b0edf78097a0d29b1bde3c260a36af4 (patch) | |
tree | 482e126fc249cc7210ecf28a20de8328c44c983c /playlist.c | |
parent | e09702f21f6313b0a44fcfcb10ee06dd70364b2f (diff) |
added new APIs for saving current playlist
Diffstat (limited to 'playlist.c')
-rw-r--r-- | playlist.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -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); +} |