setVideoSurfaceTexture is now synchronous and applied dynamically
while playing.
Change-Id: If9f08659a01bdc7dac0999730368e9dfa5e58d36
related-to-bug: 5666482
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
index d03601f..a485dda 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
@@ -29,6 +29,7 @@
NuPlayerDriver::NuPlayerDriver()
: mResetInProgress(false),
+ mSetSurfaceInProgress(false),
mDurationUs(-1),
mPositionUs(-1),
mNumFramesTotal(0),
@@ -97,7 +98,19 @@
status_t NuPlayerDriver::setVideoSurfaceTexture(
const sp<ISurfaceTexture> &surfaceTexture) {
- mPlayer->setVideoSurfaceTexture(surfaceTexture);
+ Mutex::Autolock autoLock(mLock);
+
+ if (mResetInProgress) {
+ return INVALID_OPERATION;
+ }
+
+ mSetSurfaceInProgress = true;
+
+ mPlayer->setVideoSurfaceTextureAsync(surfaceTexture);
+
+ while (mSetSurfaceInProgress) {
+ mCondition.wait(mLock);
+ }
return OK;
}
@@ -308,6 +321,13 @@
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;