From b4211c1c233933d109bc71b640013e14afc58d4a Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 20 Dec 2016 15:45:28 +0100 Subject: winrt: Fix pause/play for videos This is partially a revert of bff19dbe6733d245. While that commit fixed switching cameras it did not respect pausing a video, where setActive is called from a different thread than in the camera case. Using shutdown introduced a wait, which in that case deadlocked. Instead revert to request an interrupt, but when restarting make sure that the render thread is on hold before start is invoked. Task-number: QTBUG-53722 Change-Id: Id5a722911bb2c30509fabb73bec925cadbf77628 Reviewed-by: Oliver Wolff --- src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp index 561d9e03c..b3fd11111 100644 --- a/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp +++ b/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp @@ -356,6 +356,13 @@ void QWinRTAbstractVideoRendererControl::setActive(bool active) if (!d->surface) return; + // This only happens for quick restart scenarios, for instance + // when switching cameras. + if (d->renderThread.isRunning() && d->renderThread.isInterruptionRequested()) { + CriticalSectionLocker lock(&d->mutex); + d->renderThread.wait(); + } + if (!d->surface->isActive()) d->surface->start(d->format); @@ -363,7 +370,8 @@ void QWinRTAbstractVideoRendererControl::setActive(bool active) return; } - shutdown(); + d->renderThread.requestInterruption(); + if (d->surface && d->surface->isActive()) d->surface->stop(); } -- cgit v1.2.3