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

Commit 04925a40 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 82001647
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1279,10 +1279,17 @@ void MediaPlayerService::Client::notify(
        if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) {
            if (client->mAudioOutput != NULL)
                client->mAudioOutput->switchToNextOutput();
            client->mNextClient->start();
            if (client->mNextClient->mClient != NULL) {

            ALOGD("gapless:current track played back");
            ALOGD("gapless:try to do a gapless switch to next track");

            if (client->mNextClient->start() == NO_ERROR &&
                client->mNextClient->mClient != NULL) {
                client->mNextClient->mClient->notify(
                        MEDIA_INFO, MEDIA_INFO_STARTED_AS_NEXT, 0, obj);
            } else if (client->mClient != NULL) {
                client->mClient->notify(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN , 0, obj);
                ALOGE("gapless:start playback for next track failed");
            }
        }
    }