summaryrefslogtreecommitdiffstats
path: root/media/mca
diff options
context:
space:
mode:
authorPannag Sanketi <psanketi@google.com>2012-05-18 11:38:37 -0700
committerPannag Sanketi <psanketi@google.com>2012-06-20 19:23:48 -0700
commit22f2a8728ee2000a01aa6fc6108d8478d7c0ced9 (patch)
tree8a7fceac06445181536287a0a0993cd43d6907e9 /media/mca
parentfce2ec4da468c2d5ba26de8d051ff7ee64bb01c3 (diff)
downloadframeworks_base-22f2a8728ee2000a01aa6fc6108d8478d7c0ced9.zip
frameworks_base-22f2a8728ee2000a01aa6fc6108d8478d7c0ced9.tar.gz
frameworks_base-22f2a8728ee2000a01aa6fc6108d8478d7c0ced9.tar.bz2
Crash in SurfaceTextureTarget filter open
If the filter graph in an app closes out, the SurfaceTextureTarget filter was losing the reference to the original surfacetexture, and the app would re-start the graph without setting the surfacetexture again, thus leading to a crash in registering a surface from surfacetexture. Typical scenarios is start/stop immediately in camera effects recording. Fix part of b/6651352 Fix part of b/6655597 Change-Id: Ib2bae7e886784e91b3a886f7ccd439ff190feb22
Diffstat (limited to 'media/mca')
-rw-r--r--media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java b/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
index 674a2bd..b6d9f94 100644
--- a/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
+++ b/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
@@ -162,6 +162,10 @@ public class SurfaceTextureTarget extends Filter {
@Override
public synchronized void open(FilterContext context) {
// Set up SurfaceTexture internals
+ if (mSurfaceTexture == null) {
+ Log.e(TAG, "SurfaceTexture is null!!");
+ throw new RuntimeException("Could not register SurfaceTexture: " + mSurfaceTexture);
+ }
mSurfaceId = context.getGLEnvironment().registerSurfaceTexture(
mSurfaceTexture, mScreenWidth, mScreenHeight);
if (mSurfaceId <= 0) {
@@ -170,19 +174,24 @@ public class SurfaceTextureTarget extends Filter {
}
+ // Once the surface is unregistered, we still need the surfacetexture reference.
+ // That is because when the the filter graph stops and starts again, the app
+ // may not set the mSurfaceTexture again on the filter. In some cases, the app
+ // may not even know that the graph has re-started. So it is difficult to enforce
+ // that condition on an app using this filter. The only case where we need
+ // to let go of the mSurfaceTexure reference is when the app wants to shut
+ // down the graph on purpose, such as in the disconnect call.
@Override
public synchronized void close(FilterContext context) {
if (mSurfaceId > 0) {
context.getGLEnvironment().unregisterSurfaceId(mSurfaceId);
mSurfaceId = -1;
- // Once the surface is unregistered, remove the surfacetexture reference.
- // The surfaceId could not have been valid without a valid surfacetexture.
- mSurfaceTexture = null;
}
}
// This should be called from the client side when the surfacetexture is no longer
// valid. e.g. from onPause() in the application using the filter graph.
+ // In this case, we need to let go of our surfacetexture reference.
public synchronized void disconnect(FilterContext context) {
if (mLogVerbose) Log.v(TAG, "disconnect");
if (mSurfaceTexture == null) {