summaryrefslogtreecommitdiffstats
path: root/media/mca
diff options
context:
space:
mode:
authorPannag Sanketi <psanketi@google.com>2012-05-10 11:16:59 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-10 11:16:59 -0700
commit1870c69693d655b101fcc221eb14b1cd7592059d (patch)
tree756ba4a975b948caa90fac7ff8bd2607b54c8509 /media/mca
parentb86bc1058b8b9bce045ae94f7cd703d4bfecccb3 (diff)
parentb939760679caa9fdd06c862cf8218cc8f4a90ef1 (diff)
downloadframeworks_base-1870c69693d655b101fcc221eb14b1cd7592059d.zip
frameworks_base-1870c69693d655b101fcc221eb14b1cd7592059d.tar.gz
frameworks_base-1870c69693d655b101fcc221eb14b1cd7592059d.tar.bz2
Merge "Adding disconnect call to the SurfaceTextureTarget" into jb-dev
Diffstat (limited to 'media/mca')
-rw-r--r--media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java b/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
index 20e4b32..b023e42 100644
--- a/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
+++ b/media/mca/filterpacks/java/android/filterpacks/videosrc/SurfaceTextureTarget.java
@@ -110,7 +110,7 @@ public class SurfaceTextureTarget extends Filter {
}
@Override
- public void setupPorts() {
+ public synchronized void setupPorts() {
// Make sure we have a SurfaceView
if (mSurfaceTexture == null) {
throw new RuntimeException("Null SurfaceTexture passed to SurfaceTextureTarget");
@@ -158,7 +158,7 @@ public class SurfaceTextureTarget extends Filter {
}
@Override
- public void open(FilterContext context) {
+ public synchronized void open(FilterContext context) {
// Set up SurfaceTexture internals
mSurfaceId = context.getGLEnvironment().registerSurfaceTexture(
mSurfaceTexture, mScreenWidth, mScreenHeight);
@@ -169,17 +169,42 @@ public class SurfaceTextureTarget extends Filter {
@Override
- public void close(FilterContext context) {
+ 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.
+ public synchronized void disconnect(FilterContext context) {
+ if (mLogVerbose) Log.v(TAG, "disconnect");
+ if (mSurfaceTexture == null) {
+ Log.d(TAG, "SurfaceTexture is already null. Nothing to disconnect.");
+ return;
+ }
+ mSurfaceTexture = null;
+ // Make sure we unregister the surface as well if a surface was registered.
+ // There can be a situation where the surface was not registered but the
+ // surfacetexture was valid. For example, the disconnect can be called before
+ // the filter was opened. Hence, the surfaceId may not be a valid one here,
+ // and need to check for its validity.
+ if (mSurfaceId > 0) {
+ context.getGLEnvironment().unregisterSurfaceId(mSurfaceId);
+ mSurfaceId = -1;
+ }
+ }
@Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Starting frame processing");
-
+ public synchronized void process(FilterContext context) {
+ // Surface is not registered. Nothing to render into.
+ if (mSurfaceId <= 0) {
+ return;
+ }
GLEnvironment glEnv = context.getGLEnvironment();
// Get input frame
@@ -197,8 +222,6 @@ public class SurfaceTextureTarget extends Filter {
// See if we need to copy to GPU
Frame gpuFrame = null;
- if (mLogVerbose) Log.v("SurfaceTextureTarget", "Got input format: " + input.getFormat());
-
int target = input.getFormat().getTarget();
if (target != FrameFormat.TARGET_GPU) {
gpuFrame = context.getFrameManager().duplicateFrameToTarget(input,