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
1c5f7663
Commit
1c5f7663
authored
Feb 07, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/SongEnumerator: wrap song in std::unique_ptr
parent
e2a0fd7a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
33 additions
and
38 deletions
+33
-38
CloseSongEnumerator.cxx
src/playlist/CloseSongEnumerator.cxx
+2
-1
CloseSongEnumerator.hxx
src/playlist/CloseSongEnumerator.hxx
+1
-1
MemorySongEnumerator.cxx
src/playlist/MemorySongEnumerator.cxx
+2
-2
MemorySongEnumerator.hxx
src/playlist/MemorySongEnumerator.hxx
+1
-1
PlaylistQueue.cxx
src/playlist/PlaylistQueue.cxx
+1
-4
Print.cxx
src/playlist/Print.cxx
+1
-3
SongEnumerator.hxx
src/playlist/SongEnumerator.hxx
+5
-4
CuePlaylistPlugin.cxx
src/playlist/plugins/CuePlaylistPlugin.cxx
+5
-5
EmbeddedCuePlaylistPlugin.cxx
src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
+5
-5
ExtM3uPlaylistPlugin.cxx
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
+3
-3
FlacPlaylistPlugin.cxx
src/playlist/plugins/FlacPlaylistPlugin.cxx
+3
-3
M3uPlaylistPlugin.cxx
src/playlist/plugins/M3uPlaylistPlugin.cxx
+3
-3
dump_playlist.cxx
test/dump_playlist.cxx
+1
-3
No files found.
src/playlist/CloseSongEnumerator.cxx
View file @
1c5f7663
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "CloseSongEnumerator.hxx"
#include "input/InputStream.hxx"
#include "DetachedSong.hxx"
CloseSongEnumerator
::~
CloseSongEnumerator
()
{
...
...
@@ -27,7 +28,7 @@ CloseSongEnumerator::~CloseSongEnumerator()
delete
is
;
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
CloseSongEnumerator
::
NextSong
()
{
return
other
->
NextSong
();
...
...
src/playlist/CloseSongEnumerator.hxx
View file @
1c5f7663
...
...
@@ -41,7 +41,7 @@ public:
virtual
~
CloseSongEnumerator
();
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
#endif
src/playlist/MemorySongEnumerator.cxx
View file @
1c5f7663
...
...
@@ -20,13 +20,13 @@
#include "config.h"
#include "MemorySongEnumerator.hxx"
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
MemorySongEnumerator
::
NextSong
()
{
if
(
songs
.
empty
())
return
nullptr
;
auto
result
=
new
DetachedSong
(
std
::
move
(
songs
.
front
(
)));
std
::
unique_ptr
<
DetachedSong
>
result
(
new
DetachedSong
(
std
::
move
(
songs
.
front
()
)));
songs
.
pop_front
();
return
result
;
}
src/playlist/MemorySongEnumerator.hxx
View file @
1c5f7663
...
...
@@ -33,7 +33,7 @@ public:
MemorySongEnumerator
(
std
::
forward_list
<
DetachedSong
>
&&
_songs
)
:
songs
(
std
::
move
(
_songs
))
{}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
#endif
src/playlist/PlaylistQueue.cxx
View file @
1c5f7663
...
...
@@ -44,24 +44,21 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
?
PathTraitsUTF8
::
GetParent
(
uri
)
:
std
::
string
(
"."
);
DetachedSong
*
song
;
std
::
unique_ptr
<
DetachedSong
>
song
;
for
(
unsigned
i
=
0
;
i
<
end_index
&&
(
song
=
e
.
NextSong
())
!=
nullptr
;
++
i
)
{
if
(
i
<
start_index
)
{
/* skip songs before the start index */
delete
song
;
continue
;
}
if
(
!
playlist_check_translate_song
(
*
song
,
base_uri
.
c_str
(),
loader
))
{
delete
song
;
continue
;
}
unsigned
id
=
dest
.
AppendSong
(
pc
,
std
::
move
(
*
song
),
error
);
delete
song
;
if
(
id
==
0
)
return
false
;
}
...
...
src/playlist/Print.cxx
View file @
1c5f7663
...
...
@@ -41,7 +41,7 @@ playlist_provider_print(Response &r, Partition &partition,
?
PathTraitsUTF8
::
GetParent
(
uri
)
:
std
::
string
(
"."
);
DetachedSong
*
song
;
std
::
unique_ptr
<
DetachedSong
>
song
;
while
((
song
=
e
.
NextSong
())
!=
nullptr
)
{
if
(
playlist_check_translate_song
(
*
song
,
base_uri
.
c_str
(),
loader
)
&&
...
...
@@ -51,8 +51,6 @@ playlist_provider_print(Response &r, Partition &partition,
/* fallback if no detail was requested or no
detail was available */
song_print_uri
(
r
,
partition
,
*
song
);
delete
song
;
}
}
...
...
src/playlist/SongEnumerator.hxx
View file @
1c5f7663
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_SONG_ENUMERATOR_HXX
#define MPD_SONG_ENUMERATOR_HXX
#include <memory>
class
DetachedSong
;
/**
...
...
@@ -31,11 +33,10 @@ public:
virtual
~
SongEnumerator
()
{}
/**
* Obtain the next song. The caller is responsible for
* freeing the returned #Song object. Returns nullptr if
* there are no more songs.
* Obtain the next song. Returns nullptr if there are no more
* songs.
*/
virtual
DetachedSong
*
NextSong
()
=
0
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
=
0
;
};
#endif
src/playlist/plugins/CuePlaylistPlugin.cxx
View file @
1c5f7663
...
...
@@ -36,7 +36,7 @@ class CuePlaylist final : public SongEnumerator {
:
is
(
_is
),
tis
(
is
)
{
}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
static
SongEnumerator
*
...
...
@@ -45,23 +45,23 @@ cue_playlist_open_stream(InputStream &is)
return
new
CuePlaylist
(
is
);
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
CuePlaylist
::
NextSong
()
{
auto
song
=
parser
.
Get
();
if
(
song
!=
nullptr
)
return
song
.
release
()
;
return
song
;
const
char
*
line
;
while
((
line
=
tis
.
ReadLine
())
!=
nullptr
)
{
parser
.
Feed
(
line
);
song
=
parser
.
Get
();
if
(
song
!=
nullptr
)
return
song
.
release
()
;
return
song
;
}
parser
.
Finish
();
return
parser
.
Get
()
.
release
()
;
return
parser
.
Get
();
}
static
const
char
*
const
cue_playlist_suffixes
[]
=
{
...
...
src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
View file @
1c5f7663
...
...
@@ -69,7 +69,7 @@ public:
delete
parser
;
}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
static
void
...
...
@@ -124,13 +124,13 @@ embcue_playlist_open_uri(const char *uri,
return
playlist
;
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
EmbeddedCuePlaylist
::
NextSong
()
{
auto
song
=
parser
->
Get
();
if
(
song
!=
nullptr
)
{
song
->
SetURI
(
filename
);
return
song
.
release
()
;
return
song
;
}
while
(
*
next
!=
0
)
{
...
...
@@ -149,7 +149,7 @@ EmbeddedCuePlaylist::NextSong()
song
=
parser
->
Get
();
if
(
song
!=
nullptr
)
{
song
->
SetURI
(
filename
);
return
song
.
release
()
;
return
song
;
}
}
...
...
@@ -157,7 +157,7 @@ EmbeddedCuePlaylist::NextSong()
song
=
parser
->
Get
();
if
(
song
!=
nullptr
)
song
->
SetURI
(
filename
);
return
song
.
release
()
;
return
song
;
}
static
const
char
*
const
embcue_playlist_suffixes
[]
=
{
...
...
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
View file @
1c5f7663
...
...
@@ -48,7 +48,7 @@ public:
return
strcmp
(
line
,
"#EXTM3U"
)
==
0
;
}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
static
SongEnumerator
*
...
...
@@ -105,7 +105,7 @@ extm3u_parse_tag(const char *line)
return
tag
.
Commit
();
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
ExtM3uPlaylist
::
NextSong
()
{
Tag
tag
;
...
...
@@ -126,7 +126,7 @@ ExtM3uPlaylist::NextSong()
line_s
=
StripLeft
(
line_s
);
}
while
(
line_s
[
0
]
==
'#'
||
*
line_s
==
0
);
return
new
DetachedSong
(
line_s
,
std
::
move
(
tag
));
return
std
::
unique_ptr
<
DetachedSong
>
(
new
DetachedSong
(
line_s
,
std
::
move
(
tag
)
));
}
static
const
char
*
const
extm3u_suffixes
[]
=
{
...
...
src/playlist/plugins/FlacPlaylistPlugin.cxx
View file @
1c5f7663
...
...
@@ -58,10 +58,10 @@ public:
FLAC__metadata_object_delete
(
cuesheet
);
}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
FlacPlaylist
::
NextSong
()
{
const
FLAC__StreamMetadata_CueSheet
&
c
=
cuesheet
->
data
.
cue_sheet
;
...
...
@@ -82,7 +82,7 @@ FlacPlaylist::NextSong()
?
c
.
tracks
[
next_track
].
offset
:
total_samples
;
auto
*
song
=
new
DetachedSong
(
uri
);
std
::
unique_ptr
<
DetachedSong
>
song
(
new
DetachedSong
(
uri
)
);
song
->
SetStartTime
(
SongTime
::
FromScale
(
start
,
sample_rate
));
song
->
SetEndTime
(
SongTime
::
FromScale
(
end
,
sample_rate
));
return
song
;
...
...
src/playlist/plugins/M3uPlaylistPlugin.cxx
View file @
1c5f7663
...
...
@@ -33,7 +33,7 @@ public:
:
tis
(
is
)
{
}
virtual
DetachedSong
*
NextSong
()
override
;
virtual
std
::
unique_ptr
<
DetachedSong
>
NextSong
()
override
;
};
static
SongEnumerator
*
...
...
@@ -42,7 +42,7 @@ m3u_open_stream(InputStream &is)
return
new
M3uPlaylist
(
is
);
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
M3uPlaylist
::
NextSong
()
{
char
*
line_s
;
...
...
@@ -55,7 +55,7 @@ M3uPlaylist::NextSong()
line_s
=
Strip
(
line_s
);
}
while
(
line_s
[
0
]
==
'#'
||
*
line_s
==
0
);
return
new
DetachedSong
(
line_s
);
return
std
::
unique_ptr
<
DetachedSong
>
(
new
DetachedSong
(
line_s
)
);
}
static
const
char
*
const
m3u_suffixes
[]
=
{
...
...
test/dump_playlist.cxx
View file @
1c5f7663
...
...
@@ -108,7 +108,7 @@ try {
/* dump the playlist */
DetachedSong
*
song
;
std
::
unique_ptr
<
DetachedSong
>
song
;
while
((
song
=
playlist
->
NextSong
())
!=
NULL
)
{
printf
(
"%s
\n
"
,
song
->
GetURI
());
...
...
@@ -127,8 +127,6 @@ try {
(
start_ms
/
1000
)
%
60
);
tag_save
(
stdout
,
song
->
GetTag
());
delete
song
;
}
/* deinitialize everything */
...
...
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