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 12:15:01 +0000
commit79046c5d6130a6fc820c50e4e32338701f2eba58 (patch)
tree6053c1d10fb3cfea8f51de67c9ad9c21a575d884
parentbe0fb82e46d3b8ada9353b5e54f421aec84dcce0 (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
}