summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGarik Badalyan <garikb@codeaurora.org>2013-12-04 16:15:48 -0800
committerGarik Badalyan <garikb@codeaurora.org>2014-02-11 15:43:27 -0800
commit94a85446d641e61ac67c195e57c21cf22748cc78 (patch)
tree2bf98ec8f3b2818089733d9da79ab93e05811d35 /src
parent3d28ee33ba2afe50d6e0ef3b35676c77590ffc5f (diff)
downloadpackages_apps_InCallUI-94a85446d641e61ac67c195e57c21cf22748cc78.tar.gz
packages_apps_InCallUI-94a85446d641e61ac67c195e57c21cf22748cc78.tar.bz2
packages_apps_InCallUI-94a85446d641e61ac67c195e57c21cf22748cc78.zip
IMS-VT: Prevent surface texture destruction.
Prevent the camera and the far end view destruction. Change-Id: Id38f0422dcd98c13589f6a8d05c642c7cb47cbea CRs-Fixed: 598710
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);
}