Fixed a deadlock in PlaybackService when changing tracks from an IPlaybackRemote.

This commit is contained in:
casey langen 2017-02-03 08:13:28 +00:00
parent 482433e5da
commit bc87e4d28c

View File

@ -255,6 +255,11 @@ void PlaybackService::ProcessMessage(IMessage &message) {
int64 eventType = streamMessage->GetEventType();
if (eventType == StreamPlaying) {
TrackPtr track;
{
std::unique_lock<std::recursive_mutex> lock(this->playlistMutex);
if (this->nextIndex != NO_POSITION) {
/* in most cases when we get here it means that the next track is
starting, so we want to update our internal index. however, because
@ -274,13 +279,11 @@ void PlaybackService::ProcessMessage(IMessage &message) {
}
if (this->index != NO_POSITION) {
TrackPtr track;
{
std::unique_lock<std::recursive_mutex> lock(this->playlistMutex);
track = this->playlist.Get(this->index);
}
}
if (track) {
this->OnTrackChanged(this->index, track);
}
@ -364,6 +367,8 @@ bool PlaybackService::Previous() {
return false;
}
std::unique_lock<std::recursive_mutex> lock(this->playlistMutex);
if (transport.Position() > PREVIOUS_GRACE_PERIOD) {
this->Play(index);
return true;