summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceTexture.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2011-05-11 15:05:29 -0700
committer Mathias Agopian <mathias@google.com> 2011-05-11 18:01:51 -0700
commitcf46eb9817dfbfc020720d1e45b5c085252500fb (patch)
tree190889f185560f15eee5d6a572950c91606bbdc7 /libs/gui/SurfaceTexture.cpp
parent68c7794183a7dbfe3b20d4ce832f8eb79c2c619a (diff)
fix onFrameAvailable
Change-Id: I391fe9f6684ac9fd4f91416ce18b583f7087d966
Diffstat (limited to 'libs/gui/SurfaceTexture.cpp')
-rw-r--r--libs/gui/SurfaceTexture.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 55b1a9cebb..d7c449c353 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -385,6 +385,10 @@ status_t SurfaceTexture::setSynchronousMode(bool enabled) {
status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) {
LOGV("SurfaceTexture::queueBuffer");
+
+ sp<FrameAvailableListener> listener;
+
+ { // scope for the lock
Mutex::Autolock lock(mMutex);
if (buf < 0 || buf >= mBufferCount) {
LOGE("queueBuffer: slot index out of range [0, %d]: %d",
@@ -403,6 +407,10 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) {
return -EINVAL;
}
+ if (mQueue.empty()) {
+ listener = mFrameAvailableListener;
+ }
+
if (mSynchronousMode) {
// in synchronous mode we queue all buffers in a FIFO
mQueue.push_back(buf);
@@ -423,11 +431,13 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) {
mSlots[buf].mLastQueuedCrop = mNextCrop;
mSlots[buf].mLastQueuedTransform = mNextTransform;
mSlots[buf].mLastQueuedTimestamp = timestamp;
+ mDequeueCondition.signal();
+ } // scope for the lock
- if (mFrameAvailableListener != 0) {
- mFrameAvailableListener->onFrameAvailable();
+ // call back without lock held
+ if (listener != 0) {
+ listener->onFrameAvailable();
}
- mDequeueCondition.signal();
return OK;
}
@@ -463,6 +473,7 @@ status_t SurfaceTexture::setTransform(uint32_t transform) {
status_t SurfaceTexture::updateTexImage() {
LOGV("SurfaceTexture::updateTexImage");
+
Mutex::Autolock lock(mMutex);
int buf = mCurrentTexture;
@@ -496,7 +507,7 @@ status_t SurfaceTexture::updateTexImage() {
GLint error;
while ((error = glGetError()) != GL_NO_ERROR) {
- LOGE("GL error cleared before updating SurfaceTexture: %#04x", error);
+ LOGW("updateTexImage: clearing GL error: %#04x", error);
}
GLenum target = getTextureTarget(mSlots[buf].mGraphicBuffer->format);
@@ -539,6 +550,11 @@ status_t SurfaceTexture::updateTexImage() {
return OK;
}
+size_t SurfaceTexture::getQueuedCount() const {
+ Mutex::Autolock lock(mMutex);
+ return mQueue.size();
+}
+
bool SurfaceTexture::isExternalFormat(uint32_t format)
{
switch (format) {