OSDN Git Service

SurfaceTexture: add the abandon method.
authorJamie Gennis <jgennis@google.com>
Tue, 19 Jul 2011 19:08:33 +0000 (12:08 -0700)
committerJamie Gennis <jgennis@google.com>
Fri, 22 Jul 2011 21:20:41 +0000 (14:20 -0700)
This change adds the 'abandon' method to the SurfaceTexture C++ class.
This method may be used to put the SurfaceTexture in an abandoned state,
causing all ISurfaceTexture methods to fail.

Change-Id: Ibd261f7b73f44e2bec36a8508bf92113cfb7cf95

include/media/stagefright/SurfaceMediaSource.h
media/libstagefright/SurfaceMediaSource.cpp

index 6726d2d..4251ba9 100644 (file)
@@ -81,7 +81,7 @@ public:
     // SurfaceMediaSource object (i.e. they are not owned by the client).
     virtual status_t setBufferCount(int bufferCount);
 
-    virtual sp<GraphicBuffer> requestBuffer(int buf);
+    virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
 
     // dequeueBuffer gets the next buffer slot index for the client to use. If a
     // buffer slot is available then that slot index is written to the location
index 37b9b82..7d08f09 100644 (file)
@@ -147,16 +147,17 @@ status_t SurfaceMediaSource::setBufferCount(int bufferCount) {
     return OK;
 }
 
-sp<GraphicBuffer> SurfaceMediaSource::requestBuffer(int buf) {
+status_t SurfaceMediaSource::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
     LOGV("SurfaceMediaSource::requestBuffer");
     Mutex::Autolock lock(mMutex);
-    if (buf < 0 || mBufferCount <= buf) {
+    if (slot < 0 || mBufferCount <= slot) {
         LOGE("requestBuffer: slot index out of range [0, %d]: %d",
-                mBufferCount, buf);
-        return 0;
+                mBufferCount, slot);
+        return BAD_VALUE;
     }
-    mSlots[buf].mRequestBufferCalled = true;
-    return mSlots[buf].mGraphicBuffer;
+    mSlots[slot].mRequestBufferCalled = true;
+    *buf = mSlots[slot].mGraphicBuffer;
+    return NO_ERROR;
 }
 
 status_t SurfaceMediaSource::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,