summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2022-11-01 10:58:52 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-03 13:04:23 +0000
commite14e15682e83b52b4da50387d3e7831395146903 (patch)
treec2b347773c996621fef9b40b7f17c1aab490d1cf
parenta2918f5e1c9f770043d98e2c482adf54d7284e82 (diff)
QAVFCameraBase: Get max digital zoom factor from the active format
The camera device's maxAvailableVideoZoomFactor is equal to the device's format videoMaxZoomFactor value on single camera devices, but this is not the case for devices with dual/triple cameras. If we then set the device's zoom factor to a value bigger than the format's videoMaxZoomFactor, this can lead to a crash. So to be on the safe side, get the maximum zoom factor from the format rather than device. Also, directly set the videoZoomFactor of the device if the rate is 0, since setting the factor using rampToVideoZoomFactor:withRate: with a rate of 0, doesn't have any effect. Fixes: QTBUG-108009 Change-Id: Icf7fcdacefd3b1e0084e8ef6cf4de97c6b1b4996 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit bc01f4e7c459a591f476dbd23d95ead4c48035ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/darwin/camera/qavfcamerabase.mm11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm b/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm
index f9e353558..a11290a8d 100644
--- a/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm
+++ b/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm
@@ -456,7 +456,7 @@ void QAVFCameraBase::updateCameraConfiguration()
}
minimumZoomFactorChanged(captureDevice.minAvailableVideoZoomFactor);
- maximumZoomFactorChanged(captureDevice.maxAvailableVideoZoomFactor);
+ maximumZoomFactorChanged(captureDevice.activeFormat.videoMaxZoomFactor);
captureDevice.videoZoomFactor = zoomFactor();
@@ -570,7 +570,8 @@ void QAVFCameraBase::zoomTo(float factor, float rate)
if (!captureDevice || !captureDevice.activeFormat)
return;
- factor = qBound(captureDevice.minAvailableVideoZoomFactor, factor, captureDevice.maxAvailableVideoZoomFactor);
+ factor = qBound(captureDevice.minAvailableVideoZoomFactor, factor,
+ captureDevice.activeFormat.videoMaxZoomFactor);
const AVFConfigurationLock lock(captureDevice);
if (!lock) {
@@ -578,10 +579,10 @@ void QAVFCameraBase::zoomTo(float factor, float rate)
return;
}
- if (rate < 0)
+ if (rate <= 0)
captureDevice.videoZoomFactor = factor;
- else
- [captureDevice rampToVideoZoomFactor:factor withRate:rate];
+ else
+ [captureDevice rampToVideoZoomFactor:factor withRate:rate];
#endif
}