Commit e2a0fd7a authored by Max Kellermann's avatar Max Kellermann

playlist/cue/CueParser: Get() returns std::unique_ptr

parent 5869a4ba
...@@ -281,7 +281,7 @@ CueParser::Finish() ...@@ -281,7 +281,7 @@ CueParser::Finish()
end = true; end = true;
} }
DetachedSong * std::unique_ptr<DetachedSong>
CueParser::Get() CueParser::Get()
{ {
if (finished == nullptr && end) { if (finished == nullptr && end) {
...@@ -293,5 +293,7 @@ CueParser::Get() ...@@ -293,5 +293,7 @@ CueParser::Get()
previous.reset(); previous.reset();
} }
return finished.release(); auto result = std::move(finished);
finished.reset();
return result;
} }
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
* @return a song object that must be freed by the caller, or NULL if * @return a song object that must be freed by the caller, or NULL if
* no song was finished at this time * no song was finished at this time
*/ */
DetachedSong *Get(); std::unique_ptr<DetachedSong> Get();
private: private:
gcc_pure gcc_pure
......
...@@ -48,20 +48,20 @@ cue_playlist_open_stream(InputStream &is) ...@@ -48,20 +48,20 @@ cue_playlist_open_stream(InputStream &is)
DetachedSong * DetachedSong *
CuePlaylist::NextSong() CuePlaylist::NextSong()
{ {
DetachedSong *song = parser.Get(); auto song = parser.Get();
if (song != nullptr) if (song != nullptr)
return song; return song.release();
const char *line; const char *line;
while ((line = tis.ReadLine()) != nullptr) { while ((line = tis.ReadLine()) != nullptr) {
parser.Feed(line); parser.Feed(line);
song = parser.Get(); song = parser.Get();
if (song != nullptr) if (song != nullptr)
return song; return song.release();
} }
parser.Finish(); parser.Finish();
return parser.Get(); return parser.Get().release();
} }
static const char *const cue_playlist_suffixes[] = { static const char *const cue_playlist_suffixes[] = {
......
...@@ -127,10 +127,10 @@ embcue_playlist_open_uri(const char *uri, ...@@ -127,10 +127,10 @@ embcue_playlist_open_uri(const char *uri,
DetachedSong * DetachedSong *
EmbeddedCuePlaylist::NextSong() EmbeddedCuePlaylist::NextSong()
{ {
DetachedSong *song = parser->Get(); auto song = parser->Get();
if (song != nullptr) { if (song != nullptr) {
song->SetURI(filename); song->SetURI(filename);
return song; return song.release();
} }
while (*next != 0) { while (*next != 0) {
...@@ -149,7 +149,7 @@ EmbeddedCuePlaylist::NextSong() ...@@ -149,7 +149,7 @@ EmbeddedCuePlaylist::NextSong()
song = parser->Get(); song = parser->Get();
if (song != nullptr) { if (song != nullptr) {
song->SetURI(filename); song->SetURI(filename);
return song; return song.release();
} }
} }
...@@ -157,7 +157,7 @@ EmbeddedCuePlaylist::NextSong() ...@@ -157,7 +157,7 @@ EmbeddedCuePlaylist::NextSong()
song = parser->Get(); song = parser->Get();
if (song != nullptr) if (song != nullptr)
song->SetURI(filename); song->SetURI(filename);
return song; return song.release();
} }
static const char *const embcue_playlist_suffixes[] = { static const char *const embcue_playlist_suffixes[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment