WebRTCDemo: remove unnecessary stop & start during orientation change which isn't necessary since API v14.

(required bumping minSdkVersion to 14)

This fixes a RuntimeException thrown on GalaxyNexus (but not N7, N4, or NS)
during startPreview() after the sequence of Start(), Stop(), Start(); seemingly
GN's OMX stack can't deal with parallel startPreview() & setPreviewDisplay() in
this situation.

Also:
- Only set the surface in the camera when valid
- Remove duplicate assignment
- Fix error check on voiceChannel allocation to account for multiple channel creation due to orientation change causing onDestroy()/onCreate() on the app, and rampant use of process-static holders for VoE data.

BUG=1537

Review URL: https://webrtc-codereview.appspot.com/1259005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3731 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2013-03-27 16:48:34 +00:00
parent bfacda60be
commit add50b94a5
3 changed files with 20 additions and 36 deletions

View File

@ -125,7 +125,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
isCaptureRunning = true; isCaptureRunning = true;
previewBufferLock.unlock(); previewBufferLock.unlock();
isCaptureRunning = true;
return 0; return 0;
} }
@ -135,7 +134,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
// Get the local preview SurfaceHolder from the static render class // Get the local preview SurfaceHolder from the static render class
localPreview = ViERenderer.GetLocalRenderer(); localPreview = ViERenderer.GetLocalRenderer();
if (localPreview != null) { if (localPreview != null) {
if (localPreview.getSurface() != null) { if (localPreview.getSurface() != null &&
localPreview.getSurface().isValid()) {
surfaceCreated(localPreview); surfaceCreated(localPreview);
} }
localPreview.addCallback(this); localPreview.addCallback(this);
@ -210,18 +210,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
public void SetPreviewRotation(int rotation) { public void SetPreviewRotation(int rotation) {
Log.v(TAG, "SetPreviewRotation:" + rotation); Log.v(TAG, "SetPreviewRotation:" + rotation);
if (camera != null) { if (camera == null) {
previewBufferLock.lock(); return;
int width = 0;
int height = 0;
int framerate = 0;
boolean wasCaptureRunning = isCaptureRunning;
if (isCaptureRunning) {
width = mCaptureWidth;
height = mCaptureHeight;
framerate = mCaptureFPS;
StopCapture();
} }
int resultRotation = 0; int resultRotation = 0;
@ -237,12 +227,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
resultRotation = rotation; resultRotation = rotation;
} }
camera.setDisplayOrientation(resultRotation); camera.setDisplayOrientation(resultRotation);
if (wasCaptureRunning) {
StartCapture(width, height, framerate);
}
previewBufferLock.unlock();
}
} }
public void surfaceChanged(SurfaceHolder holder, public void surfaceChanged(SurfaceHolder holder,

View File

@ -18,7 +18,7 @@
</activity> </activity>
</application> </application>
<uses-sdk android:minSdkVersion="10" /> <uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.CAMERA"></uses-permission> <uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.autofocus" />

View File

@ -739,7 +739,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
// Create channel // Create channel
voiceChannel = vieAndroidAPI.VoE_CreateChannel(); voiceChannel = vieAndroidAPI.VoE_CreateChannel();
if (0 != voiceChannel) { if (0 > voiceChannel) {
Log.d(TAG, "VoE create channel failed"); Log.d(TAG, "VoE create channel failed");
return -1; return -1;
} }