diff options
author | Chong Zhang <chz@google.com> | 2014-08-25 08:22:24 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-08-25 08:22:24 +0000 |
commit | 5b85cf56f1c0ce4f41431aec929f3405a9c8abd4 (patch) | |
tree | 62f111f4d46b353f27a6dbb9f78ccbac14afe744 | |
parent | 13230af83d97d96110a9e1fd04f5c7964314764e (diff) | |
parent | 008cee913577839d2377ff79bf4f26655c3a2c7d (diff) | |
download | frameworks_av-5b85cf56f1c0ce4f41431aec929f3405a9c8abd4.zip frameworks_av-5b85cf56f1c0ce4f41431aec929f3405a9c8abd4.tar.gz frameworks_av-5b85cf56f1c0ce4f41431aec929f3405a9c8abd4.tar.bz2 |
am 008cee91: am 052efa49: Merge "wait for flush to finish before returning setSurface" into lmp-dev
* commit '008cee913577839d2377ff79bf4f26655c3a2c7d':
wait for flush to finish before returning setSurface
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 7 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 20 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.h | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 60f0b8c..b79a5dd 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1732,6 +1732,13 @@ void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) { // XXX - ignore error from setVideoScalingMode for now setVideoScalingMode(mVideoScalingMode); + + if (mDriver != NULL) { + sp<NuPlayerDriver> driver = mDriver.promote(); + if (driver != NULL) { + driver->notifySetSurfaceComplete(); + } + } } void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 607ce4c..6ef0ec4 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -34,6 +34,7 @@ NuPlayerDriver::NuPlayerDriver() : mState(STATE_IDLE), mIsAsyncPrepare(false), mAsyncResult(UNKNOWN_ERROR), + mSetSurfaceInProgress(false), mDurationUs(-1), mPositionUs(-1), mNotifyTimeRealUs(-1), @@ -136,6 +137,10 @@ status_t NuPlayerDriver::setVideoSurfaceTexture( const sp<IGraphicBufferProducer> &bufferProducer) { Mutex::Autolock autoLock(mLock); + if (mSetSurfaceInProgress) { + return INVALID_OPERATION; + } + switch (mState) { case STATE_SET_DATASOURCE_PENDING: case STATE_RESET_IN_PROGRESS: @@ -145,8 +150,14 @@ status_t NuPlayerDriver::setVideoSurfaceTexture( break; } + mSetSurfaceInProgress = true; + mPlayer->setVideoSurfaceTextureAsync(bufferProducer); + while (mSetSurfaceInProgress) { + mCondition.wait(mLock); + } + return OK; } @@ -544,6 +555,15 @@ void NuPlayerDriver::notifyResetComplete() { mCondition.broadcast(); } +void NuPlayerDriver::notifySetSurfaceComplete() { + Mutex::Autolock autoLock(mLock); + + CHECK(mSetSurfaceInProgress); + mSetSurfaceInProgress = false; + + mCondition.broadcast(); +} + void NuPlayerDriver::notifyDuration(int64_t durationUs) { Mutex::Autolock autoLock(mLock); mDurationUs = durationUs; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h index b0a52ad..e81d605 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h @@ -66,6 +66,7 @@ struct NuPlayerDriver : public MediaPlayerInterface { void notifySetDataSourceCompleted(status_t err); void notifyPrepareCompleted(status_t err); void notifyResetComplete(); + void notifySetSurfaceComplete(); void notifyDuration(int64_t durationUs); void notifyPosition(int64_t positionUs); void notifySeekComplete(); @@ -102,6 +103,7 @@ private: // The following are protected through "mLock" // >>> + bool mSetSurfaceInProgress; int64_t mDurationUs; int64_t mPositionUs; int64_t mNotifyTimeRealUs; |