ctor public SurfaceTexture(int, boolean);
method public long getTimestamp();
method public void getTransformMatrix(float[]);
+ method public void release();
method public void setOnFrameAvailableListener(android.graphics.SurfaceTexture.OnFrameAvailableListener);
method public void updateTexImage();
}
}
mLayer.destroy();
+ mSurface.release();
mSurface = null;
mLayer = null;
}
return surfaceTexture->getTimestamp();
}
+static void SurfaceTexture_release(JNIEnv* env, jobject thiz)
+{
+ sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
+ surfaceTexture->abandon();
+}
+
// ----------------------------------------------------------------------------
static JNINativeMethod gSurfaceTextureMethods[] = {
{"nativeUpdateTexImage", "()V", (void*)SurfaceTexture_updateTexImage },
{"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix },
{"nativeGetTimestamp", "()J", (void*)SurfaceTexture_getTimestamp },
+ {"nativeRelease", "()V", (void*)SurfaceTexture_release },
};
int register_android_graphics_SurfaceTexture(JNIEnv* env)
return nativeGetTimestamp();
}
+ /**
+ * release() frees all the buffers and puts the SurfaceTexture into the
+ * 'abandoned' state. Once put in this state the SurfaceTexture can never
+ * leave it. When in the 'abandoned' state, all methods of the
+ * ISurfaceTexture interface will fail with the NO_INIT error.
+ *
+ * Note that while calling this method causes all the buffers to be freed
+ * from the perspective of the the SurfaceTexture, if there are additional
+ * references on the buffers (e.g. if a buffer is referenced by a client or
+ * by OpenGL ES as a texture) then those buffer will remain allocated.
+ *
+ * Always call this method when you are done with SurfaceTexture. Failing
+ * to do so may delay resource deallocation for a significant amount of
+ * time.
+ */
+ public void release() {
+ nativeRelease();
+ }
+
protected void finalize() throws Throwable {
try {
nativeFinalize();
private native void nativeSetDefaultBufferSize(int width, int height);
private native void nativeUpdateTexImage();
private native int nativeGetQueuedCount();
+ private native void nativeRelease();
/*
* We use a class initializer to allow the native code to cache some
Mutex::Autolock lock(mMutex);
freeAllBuffers();
mAbandoned = true;
+ mCurrentTextureBuf.clear();
mDequeueCondition.signal();
}