Handle any exception in Camera.setPreviewTexture.
On Meizu devices (and maybe on other devices too) when camera is disallowed in settings `android.hardware.Camera.open` returns non-null Camera instance, but when any method is invoked on `Camera` instance the `RuntimeException` is thrown. It claims that Camera instance is used after `release()` was invoked on that instance. `Camera1Session.open` didn't handle that case and crashed whole application when returned Camera instance was already released or more likely was not even properly initialized during `Camera.open`. Bug: webrtc:8685 Change-Id: I5cda397a599e87971bf9a4bd3faf6fc4a0d198f3 Reviewed-on: https://webrtc-review.googlesource.com/36300 Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21556}
This commit is contained in:
committed by
Commit Bot
parent
c73e1f4378
commit
77a47e0081
@ -77,7 +77,7 @@ class Camera1Session implements CameraSession {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture());
|
camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture());
|
||||||
} catch (IOException e) {
|
} catch (IOException | RuntimeException e) {
|
||||||
camera.release();
|
camera.release();
|
||||||
callback.onFailure(FailureType.ERROR, e.getMessage());
|
callback.onFailure(FailureType.ERROR, e.getMessage());
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user