diff options
author | Andreas Huber <andih@google.com> | 2013-04-25 15:11:19 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2013-04-25 15:11:19 -0700 |
commit | 5a7501304d815552c3bfaee8789821e4884d073b (patch) | |
tree | 944512c454d0add19a0ff4036299495e3fd32027 /media/libmediaplayerservice | |
parent | 159ef7310215bdf86f7d64a797cce3ff61951a2c (diff) | |
download | frameworks_av-5a7501304d815552c3bfaee8789821e4884d073b.zip frameworks_av-5a7501304d815552c3bfaee8789821e4884d073b.tar.gz frameworks_av-5a7501304d815552c3bfaee8789821e4884d073b.tar.bz2 |
Handle the case where an asynchronous prepare was initiated and then
the mediaplayer was reset.
Change-Id: Ib241747c5dc002b88a3854569c1f8340b2a8ef41
related-to-bug: 8688986
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 7 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 607ec6a..b89b1c8 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1257,6 +1257,13 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { switch (what) { case Source::kWhatPrepared: { + if (mSource == NULL) { + // This is a stale notification from a source that was + // asynchronously preparing when the client called reset(). + // We handled the reset, the source is gone. + break; + } + int32_t err; CHECK(msg->findInt32("err", &err)); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index bdafb29..68b9623 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -333,6 +333,14 @@ status_t NuPlayerDriver::reset() { case STATE_RESET_IN_PROGRESS: return INVALID_OPERATION; + case STATE_PREPARING: + { + CHECK(mIsAsyncPrepare); + + notifyListener(MEDIA_PREPARED); + break; + } + default: break; } @@ -503,6 +511,14 @@ void NuPlayerDriver::notifySetDataSourceCompleted(status_t err) { void NuPlayerDriver::notifyPrepareCompleted(status_t err) { Mutex::Autolock autoLock(mLock); + if (mState != STATE_PREPARING) { + // We were preparing asynchronously when the client called + // reset(), we sent a premature "prepared" notification and + // then initiated the reset. This notification is stale. + CHECK(mState == STATE_RESET_IN_PROGRESS || mState == STATE_IDLE); + return; + } + CHECK_EQ(mState, STATE_PREPARING); mAsyncResult = err; |