summaryrefslogtreecommitdiffstats
path: root/src/plugins/winrt/qwinrtcameracontrol.cpp
diff options
context:
space:
mode:
authorSamuel Nevala <samuel.nevala@intopalo.com>2015-11-19 09:34:08 +0200
committerSamuel Nevala <samuel.nevala@intopalo.com>2015-11-20 12:57:25 +0000
commit4b25972f9b478677ad2ba816f9601117acde8f19 (patch)
tree2e2be0e66d66fdc715bb90a464fc799e8882ea8f /src/plugins/winrt/qwinrtcameracontrol.cpp
parent5c09c4c3c7794fd49d64dc3429d157f1a4bb5a72 (diff)
winrt: Wait for focus to finish when camera stopped
Change-Id: I53918a8f7c5f50331593ad09233cd737e040e650 Task-Id: QTBUG-49527 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Matti Malinen <matti.malinen@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
Diffstat (limited to 'src/plugins/winrt/qwinrtcameracontrol.cpp')
-rw-r--r--src/plugins/winrt/qwinrtcameracontrol.cpp23
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;
}