summaryrefslogtreecommitdiff
path: root/src/player/Thread.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/player/Thread.cxx')
-rw-r--r--src/player/Thread.cxx23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index de8b80803..b9ffb281f 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -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;