From 73305d420d73d2ffabc36e5635c58ebad3b4b380 Mon Sep 17 00:00:00 2001 From: casey Date: Thu, 26 May 2016 10:13:07 -0700 Subject: [PATCH] Fixed another small race condition in transport where changing tracks right when the transport is automatically switching over to the preloaded next track could cause a crash. --- src/core/playback/Transport.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/playback/Transport.cpp b/src/core/playback/Transport.cpp index bf24498ac..f40dffe79 100644 --- a/src/core/playback/Transport.cpp +++ b/src/core/playback/Transport.cpp @@ -245,10 +245,18 @@ void Transport::RemoveActive(Player* player) { void Transport::OnPlaybackFinished(Player* player) { this->RaiseStreamEvent(Transport::StreamFinished, player); - if (this->nextPlayer) { - this->StartWithPlayer(this->nextPlayer); + bool startedNext = false; + + { + boost::recursive_mutex::scoped_lock lock(this->stateMutex); + + if (this->nextPlayer) { + this->StartWithPlayer(this->nextPlayer); + startedNext = true; + } } - else { + + if (!startedNext) { this->SetPlaybackState(Transport::PlaybackStopped); }