Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5ad21d7e
Commit
5ad21d7e
authored
Aug 21, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue_save: save song priorities
parent
ef5125f8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
7 deletions
+27
-7
NEWS
NEWS
+1
-0
playlist_edit.c
src/playlist_edit.c
+1
-1
queue.c
src/queue.c
+2
-2
queue.h
src/queue.h
+3
-1
queue_save.c
src/queue_save.c
+19
-2
test_queue_priority.c
test/test_queue_priority.c
+1
-1
No files found.
NEWS
View file @
5ad21d7e
...
...
@@ -13,6 +13,7 @@ ver 0.17.2 (2012/??/??)
* mapper: fix potential crash in file permission check
* playlist: fix use-after-free bug
* playlist: fix memory leak
* state_file: save song priorities
ver 0.17.1 (2012/07/31)
...
...
src/playlist_edit.c
View file @
5ad21d7e
...
...
@@ -83,7 +83,7 @@ playlist_append_song(struct playlist *playlist, struct player_control *pc,
queued
=
playlist_get_queued_song
(
playlist
);
id
=
queue_append
(
&
playlist
->
queue
,
song
);
id
=
queue_append
(
&
playlist
->
queue
,
song
,
0
);
if
(
playlist
->
queue
.
random
)
{
/* shuffle the new song into the list of remaining
...
...
src/queue.c
View file @
5ad21d7e
...
...
@@ -96,7 +96,7 @@ queue_modify_all(struct queue *queue)
}
unsigned
queue_append
(
struct
queue
*
queue
,
struct
song
*
song
)
queue_append
(
struct
queue
*
queue
,
struct
song
*
song
,
uint8_t
priority
)
{
unsigned
id
=
queue_generate_id
(
queue
);
...
...
@@ -106,7 +106,7 @@ queue_append(struct queue *queue, struct song *song)
.
song
=
song
,
.
id
=
id
,
.
version
=
queue
->
version
,
.
priority
=
0
,
.
priority
=
priority
,
};
queue
->
order
[
queue
->
length
]
=
queue
->
length
;
...
...
src/queue.h
View file @
5ad21d7e
...
...
@@ -280,9 +280,11 @@ queue_modify_all(struct queue *queue);
*
* If a song is not in the database (determined by
* song_in_database()), it is freed when removed from the queue.
*
* @param priority the priority of this new queue item
*/
unsigned
queue_append
(
struct
queue
*
queue
,
struct
song
*
song
);
queue_append
(
struct
queue
*
queue
,
struct
song
*
song
,
uint8_t
priority
);
/**
* Swaps two songs, addressed by their position.
...
...
src/queue_save.c
View file @
5ad21d7e
...
...
@@ -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
);
}
test/test_queue_priority.c
View file @
5ad21d7e
...
...
@@ -41,7 +41,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
queue_init
(
&
queue
,
32
);
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
songs
);
++
i
)
queue_append
(
&
queue
,
&
songs
[
i
]);
queue_append
(
&
queue
,
&
songs
[
i
]
,
0
);
assert
(
queue_length
(
&
queue
)
==
G_N_ELEMENTS
(
songs
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment