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
5ad2980d
Commit
5ad2980d
authored
Feb 03, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QueueSave: use class SongLoader
parent
ca36ac2b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
18 deletions
+23
-18
PlaylistState.cxx
src/PlaylistState.cxx
+5
-3
PlaylistState.hxx
src/PlaylistState.hxx
+2
-0
StateFile.cxx
src/StateFile.cxx
+5
-2
QueueSave.cxx
src/queue/QueueSave.cxx
+8
-12
QueueSave.hxx
src/queue/QueueSave.hxx
+3
-1
No files found.
src/PlaylistState.cxx
View file @
5ad2980d
...
@@ -103,7 +103,8 @@ playlist_state_save(FILE *fp, const struct playlist &playlist,
...
@@ -103,7 +103,8 @@ playlist_state_save(FILE *fp, const struct playlist &playlist,
}
}
static
void
static
void
playlist_state_load
(
TextFile
&
file
,
struct
playlist
&
playlist
)
playlist_state_load
(
TextFile
&
file
,
const
SongLoader
&
song_loader
,
struct
playlist
&
playlist
)
{
{
const
char
*
line
=
file
.
ReadLine
();
const
char
*
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
if
(
line
==
nullptr
)
{
...
@@ -112,7 +113,7 @@ playlist_state_load(TextFile &file, struct playlist &playlist)
...
@@ -112,7 +113,7 @@ playlist_state_load(TextFile &file, struct playlist &playlist)
}
}
while
(
!
StringStartsWith
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
while
(
!
StringStartsWith
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
queue_load_song
(
file
,
line
,
playlist
.
queue
);
queue_load_song
(
file
,
song_loader
,
line
,
playlist
.
queue
);
line
=
file
.
ReadLine
();
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
if
(
line
==
nullptr
)
{
...
@@ -128,6 +129,7 @@ playlist_state_load(TextFile &file, struct playlist &playlist)
...
@@ -128,6 +129,7 @@ playlist_state_load(TextFile &file, struct playlist &playlist)
bool
bool
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
const
SongLoader
&
song_loader
,
struct
playlist
&
playlist
,
PlayerControl
&
pc
)
struct
playlist
&
playlist
,
PlayerControl
&
pc
)
{
{
int
current
=
-
1
;
int
current
=
-
1
;
...
@@ -183,7 +185,7 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -183,7 +185,7 @@ playlist_state_restore(const char *line, TextFile &file,
(
PLAYLIST_STATE_FILE_CURRENT
)]));
(
PLAYLIST_STATE_FILE_CURRENT
)]));
}
else
if
(
StringStartsWith
(
line
,
}
else
if
(
StringStartsWith
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN
))
{
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN
))
{
playlist_state_load
(
file
,
playlist
);
playlist_state_load
(
file
,
song_loader
,
playlist
);
}
}
}
}
...
...
src/PlaylistState.hxx
View file @
5ad2980d
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
struct
playlist
;
struct
playlist
;
struct
PlayerControl
;
struct
PlayerControl
;
class
TextFile
;
class
TextFile
;
class
SongLoader
;
void
void
playlist_state_save
(
FILE
*
fp
,
const
playlist
&
playlist
,
playlist_state_save
(
FILE
*
fp
,
const
playlist
&
playlist
,
...
@@ -37,6 +38,7 @@ playlist_state_save(FILE *fp, const playlist &playlist,
...
@@ -37,6 +38,7 @@ playlist_state_save(FILE *fp, const playlist &playlist,
bool
bool
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
const
SongLoader
&
song_loader
,
playlist
&
playlist
,
PlayerControl
&
pc
);
playlist
&
playlist
,
PlayerControl
&
pc
);
/**
/**
...
...
src/StateFile.cxx
View file @
5ad2980d
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "fs/TextFile.hxx"
#include "fs/TextFile.hxx"
#include "Partition.hxx"
#include "Partition.hxx"
#include "mixer/Volume.hxx"
#include "mixer/Volume.hxx"
#include "SongLoader.hxx"
#include "fs/FileSystem.hxx"
#include "fs/FileSystem.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
@@ -97,11 +97,14 @@ StateFile::Read()
...
@@ -97,11 +97,14 @@ StateFile::Read()
return
;
return
;
}
}
const
SongLoader
song_loader
(
nullptr
);
const
char
*
line
;
const
char
*
line
;
while
((
line
=
file
.
ReadLine
())
!=
NULL
)
{
while
((
line
=
file
.
ReadLine
())
!=
NULL
)
{
success
=
read_sw_volume_state
(
line
,
partition
.
outputs
)
||
success
=
read_sw_volume_state
(
line
,
partition
.
outputs
)
||
audio_output_state_read
(
line
,
partition
.
outputs
)
||
audio_output_state_read
(
line
,
partition
.
outputs
)
||
playlist_state_restore
(
line
,
file
,
partition
.
playlist
,
playlist_state_restore
(
line
,
file
,
song_loader
,
partition
.
playlist
,
partition
.
pc
);
partition
.
pc
);
if
(
!
success
)
if
(
!
success
)
FormatError
(
state_file_domain
,
FormatError
(
state_file_domain
,
...
...
src/queue/QueueSave.cxx
View file @
5ad2980d
...
@@ -23,10 +23,10 @@
...
@@ -23,10 +23,10 @@
#include "PlaylistError.hxx"
#include "PlaylistError.hxx"
#include "DetachedSong.hxx"
#include "DetachedSong.hxx"
#include "SongSave.hxx"
#include "SongSave.hxx"
#include "db/DatabaseSong.hxx"
#include "SongLoader.hxx"
#include "playlist/PlaylistSong.hxx"
#include "fs/TextFile.hxx"
#include "fs/TextFile.hxx"
#include "util/StringUtil.hxx"
#include "util/StringUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "fs/Traits.hxx"
#include "fs/Traits.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
@@ -69,7 +69,8 @@ queue_save(FILE *fp, const Queue &queue)
...
@@ -69,7 +69,8 @@ queue_save(FILE *fp, const Queue &queue)
}
}
void
void
queue_load_song
(
TextFile
&
file
,
const
char
*
line
,
Queue
&
queue
)
queue_load_song
(
TextFile
&
file
,
const
SongLoader
&
loader
,
const
char
*
line
,
Queue
&
queue
)
{
{
if
(
queue
.
IsFull
())
if
(
queue
.
IsFull
())
return
;
return
;
...
@@ -87,8 +88,6 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
...
@@ -87,8 +88,6 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
if
(
StringStartsWith
(
line
,
SONG_BEGIN
))
{
if
(
StringStartsWith
(
line
,
SONG_BEGIN
))
{
const
char
*
uri
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
const
char
*
uri
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
if
(
!
uri_has_scheme
(
uri
)
&&
!
PathTraitsUTF8
::
IsAbsolute
(
uri
))
return
;
Error
error
;
Error
error
;
song
=
song_load
(
file
,
uri
,
error
);
song
=
song_load
(
file
,
uri
,
error
);
...
@@ -107,15 +106,12 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
...
@@ -107,15 +106,12 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
const
char
*
uri
=
endptr
+
1
;
const
char
*
uri
=
endptr
+
1
;
if
(
uri_has_scheme
(
uri
))
{
song
=
new
DetachedSong
(
uri
);
song
=
new
DetachedSong
(
uri
);
}
else
{
#ifdef ENABLE_DATABASE
song
=
DatabaseDetachSong
(
uri
,
IgnoreError
());
if
(
song
==
nullptr
)
#endif
return
;
}
}
if
(
!
playlist_check_translate_song
(
*
song
,
nullptr
,
loader
))
{
delete
song
;
return
;
}
}
queue
.
Append
(
std
::
move
(
*
song
),
priority
);
queue
.
Append
(
std
::
move
(
*
song
),
priority
);
...
...
src/queue/QueueSave.hxx
View file @
5ad2980d
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
struct
Queue
;
struct
Queue
;
class
TextFile
;
class
TextFile
;
class
SongLoader
;
void
void
queue_save
(
FILE
*
fp
,
const
Queue
&
queue
);
queue_save
(
FILE
*
fp
,
const
Queue
&
queue
);
...
@@ -37,6 +38,7 @@ queue_save(FILE *fp, const Queue &queue);
...
@@ -37,6 +38,7 @@ queue_save(FILE *fp, const 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
(
TextFile
&
file
,
const
char
*
line
,
Queue
&
queue
);
queue_load_song
(
TextFile
&
file
,
const
SongLoader
&
loader
,
const
char
*
line
,
Queue
&
queue
);
#endif
#endif
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