From 15951e672eaf38537c82043b0b9b14088facbd19 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 3 May 2016 09:21:57 +0200 Subject: winrt: Only set focus if supported Change-Id: Ic6dc2eb6acbd0f5167aa4bad9af08ce8aa5a456b Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/winrt/qwinrtcameracontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp') diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index effddafe3..ae42c8fa5 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -617,7 +617,7 @@ void QWinRTCameraControl::setState(QCamera::State state) } QCameraFocus::FocusModes focusMode = d->cameraFocusControl->focusMode(); - if (setFocus(focusMode) && focusMode == QCameraFocus::ContinuousFocus) + if (focusMode != 0 && setFocus(focusMode) && focusMode == QCameraFocus::ContinuousFocus) focus(); d->state = QCamera::ActiveState; -- cgit v1.2.3 From c84bdf63e4de16586eda3c45d5c3c3b2dc4fe089 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 11 May 2016 09:34:06 +0200 Subject: winrt: Fix crash when initializing certain cameras Some cameras return video properties when querying for MediaStreamType_Photo, ie. Surface Book. This caused an assert. Instead when asking for photo resolutions, only query the available image resolutions and skip results not of type image. Change-Id: Ia1886a11f47676d6713eec86f3a80c664871a968 Reviewed-by: Oliver Wolff --- src/plugins/winrt/qwinrtcameracontrol.cpp | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp') diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index effddafe3..e2d5fa67d 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -101,15 +101,30 @@ HRESULT getMediaStreamResolutions(IMediaDeviceController *device, ComPtr properties; hr = (*propertiesList)->GetAt(index, &properties); Q_ASSERT_SUCCEEDED(hr); - ComPtr videoProperties; - hr = properties.As(&videoProperties); - Q_ASSERT_SUCCEEDED(hr); - UINT32 width, height; - hr = videoProperties->get_Width(&width); - Q_ASSERT_SUCCEEDED(hr); - hr = videoProperties->get_Height(&height); - Q_ASSERT_SUCCEEDED(hr); - resolutions->append(QSize(width, height)); + if (type == MediaStreamType_VideoRecord || type == MediaStreamType_VideoPreview) { + ComPtr videoProperties; + hr = properties.As(&videoProperties); + Q_ASSERT_SUCCEEDED(hr); + UINT32 width, height; + hr = videoProperties->get_Width(&width); + Q_ASSERT_SUCCEEDED(hr); + hr = videoProperties->get_Height(&height); + Q_ASSERT_SUCCEEDED(hr); + resolutions->append(QSize(width, height)); + } else if (type == MediaStreamType_Photo) { + ComPtr imageProperties; + hr = properties.As(&imageProperties); + // Asking for Photo also returns video resolutions in addition + // We skip those, as we are only interested in image Type + if (FAILED(hr) || !imageProperties) + continue; + UINT32 width, height; + hr = imageProperties->get_Width(&width); + Q_ASSERT_SUCCEEDED(hr); + hr = imageProperties->get_Height(&height); + Q_ASSERT_SUCCEEDED(hr); + resolutions->append(QSize(width, height)); + } } return resolutions->isEmpty() ? MF_E_INVALID_FORMAT : hr; } -- cgit v1.2.3