summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2022-08-25 16:26:14 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-25 18:29:47 +0000
commitf8baef1791efdc2ae34793e3f0f76c64b5616054 (patch)
treeee1b2d080d92c16e810853add9abcf6e0df3baf8
parentca3f7d464f8a8a86083ff083d2e2689db9414999 (diff)
downloadqtmultimedia-f8baef1791efdc2ae34793e3f0f76c64b5616054.tar.gz
WMF plugin: fix race condition on acivating/stopping media session
In the case when the media session stops immediately after starting, we can get into a situation where it is still active (m_active == true). This is because QWindowsMediaDeviceSession::handleStreamingStarted() is called through the event loop because the corresponding signal is emitted from another thread. To fix the problem we need to handle this signal only in "activating" state and ignore otherwise. Change-Id: Ifb40158861885bbdd9cc847efefd6de1c442601e Reviewed-by: André de la Rocha <andre.rocha@qt.io> (cherry picked from commit 35c0beaeea49a53574bfb3a9f998c59a34d9c161) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicesession.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicesession.cpp b/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicesession.cpp
index cd907ac0e..289e48995 100644
--- a/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicesession.cpp
+++ b/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicesession.cpp
@@ -101,10 +101,12 @@ void QWindowsMediaDeviceSession::setVideoSink(QVideoSink *surface)
void QWindowsMediaDeviceSession::handleStreamingStarted()
{
- m_active = true;
- m_activating = false;
- emit activeChanged(m_active);
- emit readyForCaptureChanged(m_active);
+ if (m_activating) {
+ m_active = true;
+ m_activating = false;
+ emit activeChanged(m_active);
+ emit readyForCaptureChanged(m_active);
+ }
}
void QWindowsMediaDeviceSession::handleStreamingStopped()