リビジョン | 5ae13b7a433585fc7599800c3d07aa2fa957fe5f (tree) |
---|---|
日時 | 2018-04-08 06:23:26 |
作者 | Haynes Mathew George <hgeorge@code...> |
コミッター | Moritz Horstmann |
libmediaplayerservice:Fix deadlock on gapless start failure
Return error back to the application if start of next MediaPlayer
instance as part of gapless transition fails.
Test: compiles
authored-by: Ashish Jain <ashishj@codeaurora.org>
Change-Id: I77c570074c7c98c996122e275161ba88298e56fc
(cherry picked from commit 9eadf496fa84603cf3ec5889990b79db8e378400)
(cherry picked from commit 6cb337596796996c3095dc8017eb36beba00dab2)
@@ -1343,16 +1343,33 @@ void MediaPlayerService::Client::notify( | ||
1343 | 1343 | Client* client = static_cast<Client*>(spListener.get()); |
1344 | 1344 | |
1345 | 1345 | sp<IMediaPlayerClient> c; |
1346 | + sp<Client> nextClient; | |
1347 | + status_t errStartNext = NO_ERROR; | |
1346 | 1348 | { |
1347 | 1349 | Mutex::Autolock l(client->mLock); |
1348 | 1350 | c = client->mClient; |
1349 | 1351 | if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) { |
1352 | + nextClient = client->mNextClient; | |
1353 | + | |
1350 | 1354 | if (client->mAudioOutput != NULL) |
1351 | 1355 | client->mAudioOutput->switchToNextOutput(); |
1352 | - client->mNextClient->start(); | |
1353 | - if (client->mNextClient->mClient != NULL) { | |
1354 | - client->mNextClient->mClient->notify( | |
1355 | - MEDIA_INFO, MEDIA_INFO_STARTED_AS_NEXT, 0, obj); | |
1356 | + | |
1357 | + errStartNext = nextClient->start(); | |
1358 | + } | |
1359 | + } | |
1360 | + | |
1361 | + if (nextClient != NULL) { | |
1362 | + sp<IMediaPlayerClient> nc; | |
1363 | + { | |
1364 | + Mutex::Autolock l(nextClient->mLock); | |
1365 | + nc = nextClient->mClient; | |
1366 | + } | |
1367 | + if (nc != NULL) { | |
1368 | + if (errStartNext == NO_ERROR) { | |
1369 | + nc->notify(MEDIA_INFO, MEDIA_INFO_STARTED_AS_NEXT, 0, obj); | |
1370 | + } else { | |
1371 | + nc->notify(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN , 0, obj); | |
1372 | + ALOGE("gapless:start playback for next track failed, err(%d)", errStartNext); | |
1356 | 1373 | } |
1357 | 1374 | } |
1358 | 1375 | } |