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
cbb1ab58
Commit
cbb1ab58
authored
Jul 25, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue_save: save tags and range of non-database songs
Use the functions song_save() and song_load() to use the same format as in the database file for those songs which need the tags.
parent
b01235e3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
13 deletions
+55
-13
playlist_state.c
src/playlist_state.c
+1
-1
queue_save.c
src/queue_save.c
+35
-5
queue_save.h
src/queue_save.h
+3
-1
song_save.c
src/song_save.c
+12
-6
song_save.h
src/song_save.h
+4
-0
No files found.
src/playlist_state.c
View file @
cbb1ab58
...
@@ -108,7 +108,7 @@ playlist_state_load(FILE *fp, GString *buffer, struct playlist *playlist)
...
@@ -108,7 +108,7 @@ playlist_state_load(FILE *fp, GString *buffer, struct playlist *playlist)
}
}
while
(
!
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
while
(
!
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
queue_load_song
(
&
playlist
->
queue
,
lin
e
);
queue_load_song
(
fp
,
buffer
,
line
,
&
playlist
->
queu
e
);
line
=
read_text_line
(
fp
,
buffer
);
line
=
read_text_line
(
fp
,
buffer
);
if
(
line
==
NULL
)
{
if
(
line
==
NULL
)
{
...
...
src/queue_save.c
View file @
cbb1ab58
...
@@ -23,11 +23,12 @@
...
@@ -23,11 +23,12 @@
#include "song.h"
#include "song.h"
#include "uri.h"
#include "uri.h"
#include "database.h"
#include "database.h"
#include "song_save.h"
#include <stdlib.h>
#include <stdlib.h>
static
void
static
void
queue_save_song
(
FILE
*
fp
,
int
idx
,
const
struct
song
*
song
)
queue_save_
database_
song
(
FILE
*
fp
,
int
idx
,
const
struct
song
*
song
)
{
{
char
*
uri
=
song_get_uri
(
song
);
char
*
uri
=
song_get_uri
(
song
);
...
@@ -35,6 +36,21 @@ queue_save_song(FILE *fp, int idx, const struct song *song)
...
@@ -35,6 +36,21 @@ queue_save_song(FILE *fp, int idx, const struct song *song)
g_free
(
uri
);
g_free
(
uri
);
}
}
static
void
queue_save_full_song
(
FILE
*
fp
,
const
struct
song
*
song
)
{
song_save
(
fp
,
song
);
}
static
void
queue_save_song
(
FILE
*
fp
,
int
idx
,
const
struct
song
*
song
)
{
if
(
song_in_database
(
song
))
queue_save_database_song
(
fp
,
idx
,
song
);
else
queue_save_full_song
(
fp
,
song
);
}
void
void
queue_save
(
FILE
*
fp
,
const
struct
queue
*
queue
)
queue_save
(
FILE
*
fp
,
const
struct
queue
*
queue
)
{
{
...
@@ -51,16 +67,29 @@ get_song(const char *uri)
...
@@ -51,16 +67,29 @@ get_song(const char *uri)
}
}
void
void
queue_load_song
(
struct
queue
*
queue
,
const
char
*
line
)
queue_load_song
(
FILE
*
fp
,
GString
*
buffer
,
const
char
*
line
,
struct
queue
*
queue
)
{
{
long
ret
;
char
*
endptr
;
struct
song
*
song
;
struct
song
*
song
;
if
(
queue_is_full
(
queue
))
if
(
queue_is_full
(
queue
))
return
;
return
;
ret
=
strtol
(
line
,
&
endptr
,
10
);
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
))
return
;
GError
*
error
=
NULL
;
song
=
song_load
(
fp
,
NULL
,
uri
,
buffer
,
&
error
);
if
(
song
==
NULL
)
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
;
}
}
else
{
char
*
endptr
;
long
ret
=
strtol
(
line
,
&
endptr
,
10
);
if
(
ret
<
0
||
*
endptr
!=
':'
||
endptr
[
1
]
==
0
)
{
if
(
ret
<
0
||
*
endptr
!=
':'
||
endptr
[
1
]
==
0
)
{
g_warning
(
"Malformed playlist line in state file"
);
g_warning
(
"Malformed playlist line in state file"
);
return
;
return
;
...
@@ -71,6 +100,7 @@ queue_load_song(struct queue *queue, const char *line)
...
@@ -71,6 +100,7 @@ queue_load_song(struct queue *queue, const char *line)
song
=
get_song
(
line
);
song
=
get_song
(
line
);
if
(
song
==
NULL
)
if
(
song
==
NULL
)
return
;
return
;
}
queue_append
(
queue
,
song
);
queue_append
(
queue
,
song
);
}
}
src/queue_save.h
View file @
cbb1ab58
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#ifndef QUEUE_SAVE_H
#ifndef QUEUE_SAVE_H
#define QUEUE_SAVE_H
#define QUEUE_SAVE_H
#include <glib.h>
#include <stdio.h>
#include <stdio.h>
struct
queue
;
struct
queue
;
...
@@ -36,6 +37,7 @@ queue_save(FILE *fp, const struct queue *queue);
...
@@ -36,6 +37,7 @@ queue_save(FILE *fp, const struct queue *queue);
* Loads one song from the state file and appends it to the queue.
* Loads one song from the state file and appends it to the queue.
*/
*/
void
void
queue_load_song
(
struct
queue
*
queue
,
const
char
*
line
);
queue_load_song
(
FILE
*
fp
,
GString
*
buffer
,
const
char
*
line
,
struct
queue
*
queue
);
#endif
#endif
src/song_save.c
View file @
cbb1ab58
...
@@ -41,11 +41,9 @@ song_save_quark(void)
...
@@ -41,11 +41,9 @@ song_save_quark(void)
return
g_quark_from_static_string
(
"song_save"
);
return
g_quark_from_static_string
(
"song_save"
);
}
}
static
int
void
song_save
(
struct
song
*
song
,
void
*
data
)
song_save
(
FILE
*
fp
,
const
struct
song
*
song
)
{
{
FILE
*
fp
=
data
;
fprintf
(
fp
,
SONG_BEGIN
"%s
\n
"
,
song
->
uri
);
fprintf
(
fp
,
SONG_BEGIN
"%s
\n
"
,
song
->
uri
);
if
(
song
->
end_ms
>
0
)
if
(
song
->
end_ms
>
0
)
...
@@ -58,20 +56,28 @@ song_save(struct song *song, void *data)
...
@@ -58,20 +56,28 @@ song_save(struct song *song, void *data)
fprintf
(
fp
,
SONG_MTIME
": %li
\n
"
,
(
long
)
song
->
mtime
);
fprintf
(
fp
,
SONG_MTIME
": %li
\n
"
,
(
long
)
song
->
mtime
);
fprintf
(
fp
,
SONG_END
"
\n
"
);
fprintf
(
fp
,
SONG_END
"
\n
"
);
}
static
int
song_save_callback
(
struct
song
*
song
,
void
*
data
)
{
FILE
*
fp
=
data
;
song_save
(
fp
,
song
);
return
0
;
return
0
;
}
}
void
songvec_save
(
FILE
*
fp
,
const
struct
songvec
*
sv
)
void
songvec_save
(
FILE
*
fp
,
const
struct
songvec
*
sv
)
{
{
songvec_for_each
(
sv
,
song_save
,
fp
);
songvec_for_each
(
sv
,
song_save
_callback
,
fp
);
}
}
struct
song
*
struct
song
*
song_load
(
FILE
*
fp
,
struct
directory
*
parent
,
const
char
*
uri
,
song_load
(
FILE
*
fp
,
struct
directory
*
parent
,
const
char
*
uri
,
GString
*
buffer
,
GError
**
error_r
)
GString
*
buffer
,
GError
**
error_r
)
{
{
struct
song
*
song
=
song_file_new
(
uri
,
parent
);
struct
song
*
song
=
parent
!=
NULL
?
song_file_new
(
uri
,
parent
)
:
song_remote_new
(
uri
);
char
*
line
,
*
colon
;
char
*
line
,
*
colon
;
enum
tag_type
type
;
enum
tag_type
type
;
const
char
*
value
;
const
char
*
value
;
...
...
src/song_save.h
View file @
cbb1ab58
...
@@ -26,10 +26,14 @@
...
@@ -26,10 +26,14 @@
#define SONG_BEGIN "song_begin: "
#define SONG_BEGIN "song_begin: "
struct
song
;
struct
songvec
;
struct
songvec
;
struct
directory
;
struct
directory
;
void
void
song_save
(
FILE
*
fp
,
const
struct
song
*
song
);
void
songvec_save
(
FILE
*
fp
,
const
struct
songvec
*
sv
);
songvec_save
(
FILE
*
fp
,
const
struct
songvec
*
sv
);
/**
/**
...
...
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