mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Fixed a deadlock in PlaybackService when changing tracks from an IPlaybackRemote.
This commit is contained in:
parent
482433e5da
commit
bc87e4d28c
@ -255,32 +255,35 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
int64 eventType = streamMessage->GetEventType();
|
||||
|
||||
if (eventType == StreamPlaying) {
|
||||
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
|
||||
things are asynchronous, this may not always be the case, especially if
|
||||
the tracks are very short, or the user is advancing through songs very
|
||||
quickly. make compare the track URIs before we update internal state. */
|
||||
if (this->nextIndex >= this->Count()) {
|
||||
this->nextIndex = NO_POSITION;
|
||||
this->transport.PrepareNextTrack("");
|
||||
return;
|
||||
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
|
||||
things are asynchronous, this may not always be the case, especially if
|
||||
the tracks are very short, or the user is advancing through songs very
|
||||
quickly. make compare the track URIs before we update internal state. */
|
||||
if (this->nextIndex >= this->Count()) {
|
||||
this->nextIndex = NO_POSITION;
|
||||
this->transport.PrepareNextTrack("");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->GetTrackAtIndex(this->nextIndex)->Uri() == streamMessage->GetUri()) {
|
||||
this->index = this->nextIndex;
|
||||
this->nextIndex = NO_POSITION;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->GetTrackAtIndex(this->nextIndex)->Uri() == streamMessage->GetUri()) {
|
||||
this->index = this->nextIndex;
|
||||
this->nextIndex = NO_POSITION;
|
||||
if (this->index != NO_POSITION) {
|
||||
track = this->playlist.Get(this->index);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -724,4 +729,4 @@ std::string PlaybackService::UriAtIndex(size_t index) {
|
||||
return track->Uri();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user