fix: handle SurfaceTexture update failures and disable still capture mirroring
This commit is contained in:
1 parent
131ccad93a
commit
5b1ec024ce
2 files changed
+17
-6
No files matched your search
@@ -3227,9 +3227,12 @@ class Camera2Controller(private val context: Context) {
|
||||
val captureBuilder = device.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
||||
addTarget(reader.surface)
|
||||
|
||||
if (!isRawCapture && shouldMirrorStillCaptureToPreview()) {
|
||||
previewSurface?.let { addTarget(it) }
|
||||
}
|
||||
// Do not mirror still capture frames to the GL preview SurfaceTexture.
|
||||
// Some camera HALs occasionally deliver a still-capture buffer that
|
||||
// SurfaceTexture.updateTexImage cannot bind as an external OES image.
|
||||
// if (!isRawCapture && shouldMirrorStillCaptureToPreview()) {
|
||||
// previewSurface?.let { addTarget(it) }
|
||||
// }
|
||||
|
||||
// 应用所有相机参数(曝光、白平衡、闪光灯、变焦、色调映射)
|
||||
// isCapture = true 确保使用完整的曝光时间(不限制长曝光)
|
||||
|
||||
@@ -927,10 +927,18 @@ class LutRenderer : GLSurfaceView.Renderer {
|
||||
var hasFreshCameraFrame = false
|
||||
synchronized(frameSyncObject) {
|
||||
if (frameAvailable) {
|
||||
surfaceTexture?.updateTexImage()
|
||||
surfaceTexture?.getTransformMatrix(stMatrix)
|
||||
try {
|
||||
surfaceTexture?.updateTexImage()
|
||||
surfaceTexture?.getTransformMatrix(stMatrix)
|
||||
hasFreshCameraFrame = true
|
||||
} catch (e: RuntimeException) {
|
||||
PLog.e(
|
||||
TAG,
|
||||
"updateTexImage failed, surfaceReady=$surfaceReady, cameraTextureId=$cameraTextureId",
|
||||
e
|
||||
)
|
||||
}
|
||||
frameAvailable = false
|
||||
hasFreshCameraFrame = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user