From 376590d668e22a918439877b55faf075427b13f3 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 13 Jan 2011 14:43:36 -0800 Subject: Implement SurfaceTexture frame-available callback. This change implements the onFrameAvailable callback for the SurfaceTexture java class. It includes the C++ SurfaceTexture code as well as the JNI and Java code to enable the callback. Change-Id: Ifd8b8e7ad46ee70cba6da1c2e96dab8045d1ea30 --- libs/gui/SurfaceTexture.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libs') diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 88f1728e54d6..1dadd5389154 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -166,6 +166,9 @@ status_t SurfaceTexture::queueBuffer(int buf) { mLastQueued = buf; mLastQueuedCrop = mNextCrop; mLastQueuedTransform = mNextTransform; + if (mFrameAvailableListener != 0) { + mFrameAvailableListener->onFrameAvailable(); + } return OK; } @@ -294,6 +297,13 @@ void SurfaceTexture::getTransformMatrix(float mtx[16]) { mtxMul(mtx, mtxFlipV, mtxBeforeFlipV); } +void SurfaceTexture::setFrameAvailableListener( + const sp& l) { + LOGV("SurfaceTexture::setFrameAvailableListener"); + Mutex::Autolock lock(mMutex); + mFrameAvailableListener = l; +} + void SurfaceTexture::freeAllBuffers() { for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { mSlots[i].mGraphicBuffer = 0; -- cgit v1.2.3-59-g8ed1b