summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Petter Skålerud <[email protected]>2025-04-09 11:43:04 +0200
committerNils Petter Skålerud <[email protected]>2025-06-03 07:22:22 +0000
commit86a930eb638434391318449475fced8b86f124ae (patch)
treed186b8ac4218f7fa40e6bcf315b66396d699945b
parent65b11b9f97632101041134e04713697b17819884 (diff)
Darwin, Camera: Solve memory leak related to rotation trackingHEADdev
The current uses a method 'updateRotationTracking()' to setup state related to tracking the rotation of the AVCaptureDevice. This method either refreshes or clears the state depending on whether the camera is active or not. During destruction of the QAVFCamera object, the camera is still in active state, and therefore sets up new rotating-tracking objects during destruction and never cleans it up. This patch solves this memory leak by introducing a method 'clearRotationTracking()' and calls it during destruction. Pick-to: 6.10 6.9 6.8 Change-Id: I1f457ae62aa781dff48b50fb1f744e71da6a7972 Reviewed-by: Tim Blechmann <[email protected]>
-rw-r--r--src/plugins/multimedia/ffmpeg/qavfcamera.mm24
-rw-r--r--src/plugins/multimedia/ffmpeg/qavfcamera_p.h1
2 files changed, 15 insertions, 10 deletions
diff --git a/src/plugins/multimedia/ffmpeg/qavfcamera.mm b/src/plugins/multimedia/ffmpeg/qavfcamera.mm
index 154f41201..f9a606375 100644
--- a/src/plugins/multimedia/ffmpeg/qavfcamera.mm
+++ b/src/plugins/multimedia/ffmpeg/qavfcamera.mm
@@ -57,7 +57,7 @@ QAVFCamera::~QAVFCamera()
[m_captureSession release];
dispatch_release(m_delegateQueue);
- updateRotationTracking();
+ clearRotationTracking();
}
void QAVFCamera::refreshAvCaptureSessionInputDevice()
@@ -372,18 +372,22 @@ void QAVFCamera::updateRotationTracking()
}
#endif
} else {
- if (@available(macOS 14.0, iOS 17.0, *)) {
- if (m_rotationCoordinator)
- [m_rotationCoordinator release];
- m_rotationCoordinator = nullptr;
- }
+ clearRotationTracking();
+ }
+}
+
+void QAVFCamera::clearRotationTracking() {
+ if (@available(macOS 14.0, iOS 17.0, *)) {
+ if (m_rotationCoordinator)
+ [m_rotationCoordinator release];
+ m_rotationCoordinator = nullptr;
+ }
#ifdef Q_OS_IOS
- if (m_receivingUiDeviceOrientationNotifications)
- [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
- m_receivingUiDeviceOrientationNotifications = false;
+ if (m_receivingUiDeviceOrientationNotifications)
+ [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
+ m_receivingUiDeviceOrientationNotifications = false;
#endif
- }
}
// Gets the current rotationfor this QAVFCamera.
diff --git a/src/plugins/multimedia/ffmpeg/qavfcamera_p.h b/src/plugins/multimedia/ffmpeg/qavfcamera_p.h
index 59c76405f..a7d32c236 100644
--- a/src/plugins/multimedia/ffmpeg/qavfcamera_p.h
+++ b/src/plugins/multimedia/ffmpeg/qavfcamera_p.h
@@ -65,6 +65,7 @@ private:
VideoTransformation surfaceTransform() const;
void updateRotationTracking();
+ void clearRotationTracking();
int getCurrentRotationAngleDegrees() const;
bool isFrontCamera() const;