summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-09-29 19:35:36 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-09-29 19:35:36 +0200
commit5fa0da2d9b0edf78097a0d29b1bde3c260a36af4 (patch)
tree482e126fc249cc7210ecf28a20de8328c44c983c /playlist.c
parente09702f21f6313b0a44fcfcb10ee06dd70364b2f (diff)
added new APIs for saving current playlist
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c28
1 files changed, 24 insertions, 4 deletions
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);
+}