|
|
@ -838,7 +838,9 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onVideoRecordingEnd() { |
|
|
|
public void onVideoRecordingEnd() { |
|
|
|
super.onVideoRecordingEnd(); |
|
|
|
super.onVideoRecordingEnd(); |
|
|
|
boolean needsIssue549Workaround = (mVideoRecorder instanceof Full2VideoRecorder) || |
|
|
|
// SnapshotRecorder will invoke this on its own thread which is risky, but if it was a
|
|
|
|
|
|
|
|
// snapshot, this function returns early so its safe.
|
|
|
|
|
|
|
|
boolean needsIssue549Workaround = (mVideoRecorder instanceof Full2VideoRecorder) && |
|
|
|
(readCharacteristic(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL, -1) |
|
|
|
(readCharacteristic(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL, -1) |
|
|
|
== CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY); |
|
|
|
== CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY); |
|
|
|
if (needsIssue549Workaround) { |
|
|
|
if (needsIssue549Workaround) { |
|
|
@ -849,8 +851,17 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception) { |
|
|
|
public void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception) { |
|
|
|
super.onVideoResult(result, exception); |
|
|
|
super.onVideoResult(result, exception); |
|
|
|
|
|
|
|
// SnapshotRecorder will invoke this on its own thread, so let's post in our own thread
|
|
|
|
|
|
|
|
// and check camera state before trying to restore the preview. Engine might have been
|
|
|
|
|
|
|
|
// torn down in the engine thread while this was still being called.
|
|
|
|
|
|
|
|
mHandler.run(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
if (getBindState() < STATE_STARTED) return; |
|
|
|
maybeRestorePreviewTemplateAfterVideo(); |
|
|
|
maybeRestorePreviewTemplateAfterVideo(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Video recorders might change the camera template to {@link CameraDevice#TEMPLATE_RECORD}. |
|
|
|
* Video recorders might change the camera template to {@link CameraDevice#TEMPLATE_RECORD}. |
|
|
@ -860,6 +871,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv |
|
|
|
* This method avoids doing this twice by checking the request tag, as set by |
|
|
|
* This method avoids doing this twice by checking the request tag, as set by |
|
|
|
* the {@link #createRepeatingRequestBuilder(int)} method. |
|
|
|
* the {@link #createRepeatingRequestBuilder(int)} method. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@EngineThread |
|
|
|
private void maybeRestorePreviewTemplateAfterVideo() { |
|
|
|
private void maybeRestorePreviewTemplateAfterVideo() { |
|
|
|
int template = (int) mRepeatingRequestBuilder.build().getTag(); |
|
|
|
int template = (int) mRepeatingRequestBuilder.build().getTag(); |
|
|
|
if (template != CameraDevice.TEMPLATE_PREVIEW) { |
|
|
|
if (template != CameraDevice.TEMPLATE_PREVIEW) { |
|
|
|