From 174976417b6a85fd81e4951cd746028358d2f60b Mon Sep 17 00:00:00 2001 From: Yamit Mehta Date: Mon, 20 Jul 2015 13:52:10 +0530 Subject: 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 --- media/libmediaplayerservice/MediaPlayerService.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) mode change 100644 => 100755 media/libmediaplayerservice/MediaPlayerService.cpp (limited to 'media/libmediaplayerservice/MediaPlayerService.cpp') diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp old mode 100644 new mode 100755 index dbe8b31..25839df --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -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"); + } } } -- cgit v1.1