summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2014-02-12 09:31:15 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2014-02-12 09:31:15 -0800
commit796fd8b883f350fde8171e193d7e84071cae49da (patch)
tree291a711e81eacdc43d708ddfe3f3802bf82c3153 /src
parent0ee8c61e84e0ac5a6eb91d25a76e63a7f8b5abf7 (diff)
parent94a85446d641e61ac67c195e57c21cf22748cc78 (diff)
downloadpackages_apps_InCallUI-796fd8b883f350fde8171e193d7e84071cae49da.tar.gz
packages_apps_InCallUI-796fd8b883f350fde8171e193d7e84071cae49da.tar.bz2
packages_apps_InCallUI-796fd8b883f350fde8171e193d7e84071cae49da.zip
Merge "IMS-VT: Prevent surface texture destruction."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/incallui/CallCardFragment.java10
-rw-r--r--src/com/android/incallui/VideoCallPanel.java55
2 files changed, 59 insertions, 6 deletions
diff --git a/src/com/android/incallui/CallCardFragment.java b/src/com/android/incallui/CallCardFragment.java
index 0772fc4c..97d02cdb 100644
--- a/src/com/android/incallui/CallCardFragment.java
+++ b/src/com/android/incallui/CallCardFragment.java
@@ -149,6 +149,16 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
@Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ if (mVideoCallPanel!=null) {
+ mVideoCallPanel.onDestroy();
+ mVideoCallPanel = null;
+ }
+ }
+
+ @Override
public void setVisible(boolean on) {
if (on) {
getView().setVisibility(View.VISIBLE);
diff --git a/src/com/android/incallui/VideoCallPanel.java b/src/com/android/incallui/VideoCallPanel.java
index 81b2d97e..d085b76a 100644
--- a/src/com/android/incallui/VideoCallPanel.java
+++ b/src/com/android/incallui/VideoCallPanel.java
@@ -65,6 +65,7 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
// "Video Call" UI elements and state
private ViewGroup mVideoCallPanel;
private ZoomControlBar mZoomControl;
+
private TextureView mFarEndView;
private TextureView mCameraPreview;
private SurfaceTexture mCameraSurface;
@@ -227,6 +228,14 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
// Set media event listener
mVideoCallManager.setMediaEventListener(new MediaEventListener());
mVideoCallManager.setCvoEventListener(new CvoListener());
+
+ releaseCachedSurfaces();
+ }
+
+ // The function must be called from the parent's onDestroy function.
+ public void onDestroy() {
+ log("onDestroy...");
+ releaseCachedSurfaces();
}
public void setCameraNeeded(boolean mCameraNeeded) {
@@ -317,7 +326,7 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
public boolean isCameraInitNeeded() {
if (DBG) {
- log("isCameraInitNeeded mCameraNeeded=" + mCameraNeeded + " mCameraSurface= "
+ log("isCameraInitNeeded mCameraNeeded=" + mCameraNeeded + " CameraSurface= "
+ mCameraSurface + " camera state = "
+ mVideoCallManager.getCameraState());
}
@@ -376,13 +385,32 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
if (surface.equals(mCameraPreview.getSurfaceTexture())) {
if (DBG) log("Camera surface texture created");
- mCameraSurface = surface;
+
+ // Use cached surface texture.
+ if (mCameraSurface==null) {
+ log("Caching camera surface texture.");
+ mCameraSurface = surface;
+ } else {
+ log("Resetting camera surface texture");
+ mCameraPreview.setSurfaceTexture(mCameraSurface);
+ }
+
+ // Initialize Camera as needed.
if (isCameraInitNeeded()) {
initializeCamera();
}
} else if (surface.equals(mFarEndView.getSurfaceTexture())) {
+
+ // Use cached surface texture.
if (DBG) log("Video surface texture created");
- mFarEndSurface = surface;
+ if (mFarEndSurface==null) {
+ log("Caching video surface texture.");
+ mFarEndSurface = surface;
+ } else {
+ log("Resetting video surface texture.");
+ mFarEndView.setSurfaceTexture(mFarEndSurface);
+ }
+
mVideoCallManager.setFarEndSurface(mFarEndSurface);
}
}
@@ -393,11 +421,10 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
if (DBG) log("CameraPreview surface texture destroyed");
stopRecordingAndPreview();
closeCamera();
- mCameraSurface = null;
+ return false;
} else if (surface.equals(mFarEndView.getSurfaceTexture())) {
if (DBG) log("FarEndView surface texture destroyed");
- mFarEndSurface = null;
- mVideoCallManager.setFarEndSurface(null);
+ return false;
}
return true;
}
@@ -648,6 +675,22 @@ public class VideoCallPanel extends RelativeLayout implements TextureView.Surfac
}
}
+ // Releases surface texture if it's not null.
+ private void release(SurfaceTexture s) {
+ if (s == null) return;
+ log("VideoCall: Releasing surface texture, " + s);
+ s.release();
+ }
+
+ private void releaseCachedSurfaces() {
+ release(mCameraSurface);
+ mCameraSurface = null;
+
+ release(mFarEndSurface);
+ mFarEndSurface = null;
+ mVideoCallManager.setFarEndSurface(mFarEndSurface);
+ }
+
public void startOrientationListener(boolean start) {
mVideoCallManager.startOrientationListener(start);
}