diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/winrt/qwinrtcameracontrol.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/winrt/qwinrtcameracontrol.cpp b/src/plugins/winrt/qwinrtcameracontrol.cpp index f04286362..19b718cdd 100644 --- a/src/plugins/winrt/qwinrtcameracontrol.cpp +++ b/src/plugins/winrt/qwinrtcameracontrol.cpp @@ -517,6 +517,7 @@ public: ComPtr<MediaSink> mediaSink; ComPtr<IFocusControl> focusControl; ComPtr<IRegionsOfInterestControl> regionsOfInterestControl; + ComPtr<IAsyncAction> focusOperation; QPointer<QWinRTCameraVideoRendererControl> videoRenderer; QPointer<QWinRTVideoDeviceSelectorControl> videoDeviceSelector; @@ -620,6 +621,11 @@ void QWinRTCameraControl::setState(QCamera::State state) case QCamera::UnloadedState: { // Stop the camera if it is running (transition to LoadedState) if (d->status == QCamera::ActiveStatus) { + HRESULT hr; + if (d->focusOperation) { + hr = QWinRTFunctions::await(d->focusOperation); + Q_ASSERT_SUCCEEDED(hr); + } if (d->framesMapped > 0) { qWarning("%d QVideoFrame(s) mapped when closing down camera. Camera will wait for unmap before closing down.", d->framesMapped); @@ -1150,17 +1156,26 @@ bool QWinRTCameraControl::setFocusPoint(const QPointF &focusPoint) bool QWinRTCameraControl::focus() { Q_D(QWinRTCameraControl); - if (!d->focusControl) + HRESULT hr; + AsyncStatus status = AsyncStatus::Completed; + if (d->focusOperation) { + ComPtr<IAsyncInfo> info; + hr = d->focusOperation.As(&info); + Q_ASSERT_SUCCEEDED(hr); + info->get_Status(&status); + } + + if (!d->focusControl || status == AsyncStatus::Started) return false; - ComPtr<IAsyncAction> op; - HRESULT hr = d->focusControl->FocusAsync(&op); + + hr = d->focusControl->FocusAsync(&d->focusOperation); const long errorCode = HRESULT_CODE(hr); if (errorCode == ERROR_OPERATION_IN_PROGRESS || errorCode == ERROR_WRITE_PROTECT) { return false; } Q_ASSERT_SUCCEEDED(hr); - hr = QWinRTFunctions::await(op, QWinRTFunctions::ProcessThreadEvents); + hr = QWinRTFunctions::await(d->focusOperation, QWinRTFunctions::ProcessThreadEvents); Q_ASSERT_SUCCEEDED(hr); return hr == S_OK; } |