aboutsummaryrefslogtreecommitdiffstats
path: root/src/queue_save.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-21 19:17:14 +0200
committerMax Kellermann <max@duempel.org>2012-08-21 19:17:14 +0200
commit5ad21d7e98e1f21e09de66c1e0275ea2ab5b74e4 (patch)
treeb8b13a0b3109aa6124877f5c6d902928c82e06db /src/queue_save.c
parentef5125f8f4ee992c5a8f24d1b93851db5df5c43d (diff)
downloadmpd-5ad21d7e98e1f21e09de66c1e0275ea2ab5b74e4.tar.gz
mpd-5ad21d7e98e1f21e09de66c1e0275ea2ab5b74e4.tar.xz
mpd-5ad21d7e98e1f21e09de66c1e0275ea2ab5b74e4.zip
queue_save: save song priorities
Diffstat (limited to 'src/queue_save.c')
-rw-r--r--src/queue_save.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/queue_save.c b/src/queue_save.c
index a7c511c0e..16852d3c1 100644
--- a/src/queue_save.c
+++ b/src/queue_save.c
@@ -24,9 +24,12 @@
#include "uri.h"
#include "database.h"
#include "song_save.h"
+#include "text_file.h"
#include <stdlib.h>
+#define PRIO_LABEL "Prio: "
+
static void
queue_save_database_song(FILE *fp, int idx, const struct song *song)
{
@@ -54,8 +57,13 @@ queue_save_song(FILE *fp, int idx, const struct song *song)
void
queue_save(FILE *fp, const struct queue *queue)
{
- for (unsigned i = 0; i < queue_length(queue); i++)
+ for (unsigned i = 0; i < queue_length(queue); i++) {
+ uint8_t prio = queue_get_priority_at_position(queue, i);
+ if (prio != 0)
+ fprintf(fp, PRIO_LABEL "%u\n", prio);
+
queue_save_song(fp, i, queue_get(queue, i));
+ }
}
static struct song *
@@ -75,6 +83,15 @@ queue_load_song(FILE *fp, GString *buffer, const char *line,
if (queue_is_full(queue))
return;
+ uint8_t priority = 0;
+ if (g_str_has_prefix(line, PRIO_LABEL)) {
+ priority = strtoul(line + sizeof(PRIO_LABEL) - 1, NULL, 10);
+
+ line = read_text_line(fp, buffer);
+ if (line == NULL)
+ return;
+ }
+
if (g_str_has_prefix(line, SONG_BEGIN)) {
const char *uri = line + sizeof(SONG_BEGIN) - 1;
if (!uri_has_scheme(uri) && !g_path_is_absolute(uri))
@@ -102,5 +119,5 @@ queue_load_song(FILE *fp, GString *buffer, const char *line,
return;
}
- queue_append(queue, song);
+ queue_append(queue, song, priority);
}