diff options
author | Doris Verria <doris.verria@qt.io> | 2022-11-01 10:58:52 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-03 13:04:23 +0000 |
commit | e14e15682e83b52b4da50387d3e7831395146903 (patch) | |
tree | c2b347773c996621fef9b40b7f17c1aab490d1cf | |
parent | a2918f5e1c9f770043d98e2c482adf54d7284e82 (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.mm | 11 |
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 } |