diff options
| author | Grace Kloba <klobag@google.com> | 2011-08-09 18:47:17 -0700 |
|---|---|---|
| committer | Grace Kloba <klobag@google.com> | 2011-08-09 18:47:17 -0700 |
| commit | 402f05530352f34d5320c2d23be43c274d97c4e2 (patch) | |
| tree | f16fff92ad3dead45679fff4ee4c7c3fdb5888bb /core/java/android/view/TextureView.java | |
| parent | 5229f7f2266c25f976070e0c2007e425010152ff (diff) | |
Add a return value for SurfaceTextureListener#onSurfaceTextureDestroyed.
If returns true, the SurfaceTexture will be released by TextureView.
If returns false, the client needs to release the SurfaceTexture.
Change-Id: I946f71e337ad4170c168854ac27e028b82489c8c
Diffstat (limited to 'core/java/android/view/TextureView.java')
| -rw-r--r-- | core/java/android/view/TextureView.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 76aa21f225c7..53a6bcba98c8 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -73,9 +73,10 @@ import android.util.Log; * // Ignored, Camera does all the work for us * } * - * public void onSurfaceTextureDestroyed(SurfaceTexture surface) { + * public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { * mCamera.stopPreview(); * mCamera.release(); + * return true; * } * * public void onSurfaceTextureUpdated(SurfaceTexture surface) { @@ -195,8 +196,9 @@ public class TextureView extends View { super.onDetachedFromWindow(); if (mLayer != null) { + boolean shouldRelease = true; if (mListener != null) { - mListener.onSurfaceTextureDestroyed(mSurface); + shouldRelease = mListener.onSurfaceTextureDestroyed(mSurface); } synchronized (mNativeWindowLock) { @@ -204,7 +206,7 @@ public class TextureView extends View { } mLayer.destroy(); - mSurface.release(); + if (shouldRelease) mSurface.release(); mSurface = null; mLayer = null; } @@ -578,12 +580,12 @@ public class TextureView extends View { /** * Invoked when the specified {@link SurfaceTexture} is about to be destroyed. - * After this method is invoked, no rendering should happen inside the surface - * texture. + * If returns true, no rendering should happen inside the surface texture after this method + * is invoked. If returns false, the client needs to call {@link SurfaceTexture#release()}. * * @param surface The surface about to be destroyed */ - public void onSurfaceTextureDestroyed(SurfaceTexture surface); + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface); /** * Invoked when the specified {@link SurfaceTexture} is updated through |
