player/Control: wrap DetachedSong* in std::unique_ptr

This commit is contained in:
Max Kellermann
2017-11-26 11:46:14 +01:00
parent b652ad9568
commit b13b023c6b
6 changed files with 59 additions and 61 deletions

View File

@@ -90,7 +90,7 @@ class Player {
/**
* the song currently being played
*/
DetachedSong *song;
std::unique_ptr<DetachedSong> song;
/**
* Is cross-fading to the next song enabled?
@@ -413,9 +413,7 @@ Player::ActivateDecoder()
pc.ClearTaggedSong();
delete song;
song = pc.next_song;
pc.next_song = nullptr;
song = std::exchange(pc.next_song, nullptr);
elapsed_time = pc.seek_time;
@@ -605,8 +603,7 @@ Player::SeekDecoder()
ClearAndReplacePipe(dc.pipe);
}
delete pc.next_song;
pc.next_song = nullptr;
pc.next_song.reset();
queued = false;
/* wait for the decoder to complete initialization
@@ -724,8 +721,7 @@ Player::ProcessCommand()
StopDecoder();
}
delete pc.next_song;
pc.next_song = nullptr;
pc.next_song.reset();
queued = false;
pc.CommandFinished();
break;
@@ -1119,7 +1115,7 @@ Player::Run()
if (song != nullptr) {
FormatDefault(player_domain, "played \"%s\"", song->GetURI());
delete song;
song.reset();
}
pc.Lock();
@@ -1128,8 +1124,7 @@ Player::Run()
if (queued) {
assert(pc.next_song != nullptr);
delete pc.next_song;
pc.next_song = nullptr;
pc.next_song.reset();
}
pc.state = PlayerState::STOP;
@@ -1179,8 +1174,7 @@ PlayerControl::RunThread() noexcept
/* fall through */
case PlayerCommand::PAUSE:
delete next_song;
next_song = nullptr;
next_song.reset();
CommandFinished();
break;
@@ -1215,8 +1209,7 @@ PlayerControl::RunThread() noexcept
return;
case PlayerCommand::CANCEL:
delete next_song;
next_song = nullptr;
next_song.reset();
CommandFinished();
break;