summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2022-11-01 10:58:52 +0100
committerDoris Verria <doris.verria@qt.io>2022-11-03 11:26:23 +0000
commitbc01f4e7c459a591f476dbd23d95ead4c48035ea (patch)
tree2d66f00fd2126ff42c6f689c81528c986b34c7e7 /src
parent68ab44b57d23ac4ecbd663233b9c978b17cd0e98 (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 Pick-to: 6.2 6.4 6.4.1 Change-Id: Icf7fcdacefd3b1e0084e8ef6cf4de97c6b1b4996 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
-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
}