From 5ed9b6d6d77c420ea02aac5f01af1e9f85731f1b Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 19 Nov 2015 15:32:48 +0100 Subject: AVFoundation: fix setting up the video capture session. Because of an incorrect 'if' condition, the video capture session was set up twice when starting the camera. Change-Id: I4211a8c77ab9b8086628fb0f12fb28842de830cf Reviewed-by: Timur Pocheptsov Reviewed-by: Yoann Lopes --- src/plugins/avfoundation/camera/avfmediarecordercontrol.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/avfoundation/camera/avfmediarecordercontrol.mm') diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm index 412dab76c..115d70864 100644 --- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm +++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm @@ -359,7 +359,7 @@ void AVFMediaRecorderControl::setupSessionForCapture() } } else if (m_connected && (!m_cameraControl->captureMode().testFlag(QCamera::CaptureVideo) - || m_session->state() != QCamera::ActiveState)) { + || m_session->state() == QCamera::UnloadedState)) { [captureSession removeOutput:m_movieOutput]; -- cgit v1.2.3 From 604a5753fa2d9b8e1ef65ccd8c5fb72465462479 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 19 Nov 2015 15:41:01 +0100 Subject: AVFoundation: correctly set the activeFormat on the AVCaptureDevice. According to the AVCaptureDevice documentation, the device must be locked before starting the capture session to prevent the activeFormat from being overridden. We now do that, but only if we explicitly set an activeFormat. Otherwise the device is not locked, which allows the session to find an appropriate format for the capture device. The device is also locked when enabling video capture, as doing so might also reset the activeFormat. Task-number: QTBUG-49170 Change-Id: I75478fd4bbfec96cd2abd2c3ae2951088b38978e Reviewed-by: Timur Pocheptsov --- src/plugins/avfoundation/camera/avfmediarecordercontrol.mm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/plugins/avfoundation/camera/avfmediarecordercontrol.mm') diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm index 115d70864..1b6e23ee5 100644 --- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm +++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm @@ -37,6 +37,7 @@ #include "avfcameraservice.h" #include "avfcameracontrol.h" #include "avfaudioinputselectorcontrol.h" +#include "avfcamerautility.h" #include #include @@ -330,6 +331,9 @@ void AVFMediaRecorderControl::setupSessionForCapture() && m_cameraControl->captureMode().testFlag(QCamera::CaptureVideo) && m_session->state() != QCamera::UnloadedState) { + // Lock the video capture device to make sure the active format is not reset + const AVFConfigurationLock lock(m_session->videoCaptureDevice()); + // Add audio input // Allow recording even if something wrong happens with the audio input initialization AVCaptureDevice *audioDevice = m_audioInputControl->createCaptureDevice(); @@ -361,6 +365,9 @@ void AVFMediaRecorderControl::setupSessionForCapture() && (!m_cameraControl->captureMode().testFlag(QCamera::CaptureVideo) || m_session->state() == QCamera::UnloadedState)) { + // Lock the video capture device to make sure the active format is not reset + const AVFConfigurationLock lock(m_session->videoCaptureDevice()); + [captureSession removeOutput:m_movieOutput]; if (m_audioInput) { -- cgit v1.2.3