Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17497641 authored by Yamit Mehta's avatar Yamit Mehta Committed by Linux Build Service Account
Browse files

libmediaplayerservice:Fix deadlock on gapless start failure

Issue:- Current gapless implementation starts the next clip when
MEDIA_PLAYBACK_COMPLETE event for the first clip is recieved
by MediaPlayerService.
-Even if start for next clip fails, application is notified with
MEDIA_INFO_STARTED_AS_NEXT.
- This causes the framework to trigger mediaplayer start which
again fails as it being for the same clip resulting in a deadlock
in the mediaplayer.
Fix:- Notify application with MEDIA_INFO_STARTED_AS_NEXT only when
start for the next clip is successful.

Change-Id: I77c570074c7c98c996122e275161ba88298e56fc
parent 88801f57
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1249,8 +1249,17 @@ void MediaPlayerService::Client::notify(
        if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) {
            if (client->mAudioOutput != NULL)
                client->mAudioOutput->switchToNextOutput();
            client->mNextClient->start();
            client->mNextClient->mClient->notify(MEDIA_INFO, MEDIA_INFO_STARTED_AS_NEXT, 0, obj);
            ALOGD("gapless:current track played back");
            ALOGD("gapless:try to do a gapless switch to next track");
            status_t ret;
            ret = client->mNextClient->start();
            if (ret == NO_ERROR) {
                client->mNextClient->mClient->notify(MEDIA_INFO,
                        MEDIA_INFO_STARTED_AS_NEXT, 0, obj);
            } else {
                client->mClient->notify(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN , 0, obj);
                ALOGW("gapless:start playback for next track failed");
            }
        }
    }