diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2023-05-16 13:08:53 +0200 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2023-05-31 16:33:55 +0000 |
commit | e243338d6465f185ba7a78a3dfb8f426a637d2cf (patch) | |
tree | d6d4fe9a87821018c288b93a0254c2ec7e4a2f02 /src | |
parent | fc1cc250d6d226dd627cefc4be617231d229e2cf (diff) |
Fix QAudioSink::stateChanged signal emitting
1. Ensure sending the signal from QAudioSink's thread.
2. QAudioSink backends emit signals from different threads what may
cause a case when queued events are outdated and should be filtered.
The patch has been decoupled from the big change
codereview.qt-project.org/c/qt/qtmultimedia/+/474485
Task-number: QTBUG-113194
Pick-to: 6.5
Change-Id: I68002c243dea814c4309b14b1fbd7b618392ab11
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/audio/qaudiosink.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/multimedia/audio/qaudiosink.cpp b/src/multimedia/audio/qaudiosink.cpp index 4bcf85f9c..e63fa5fc2 100644 --- a/src/multimedia/audio/qaudiosink.cpp +++ b/src/multimedia/audio/qaudiosink.cpp @@ -89,7 +89,12 @@ QAudioSink::QAudioSink(const QAudioDevice &audioDevice, const QAudioFormat &form { d = QPlatformMediaDevices::instance()->audioOutputDevice(format, audioDevice, parent); if (d) - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); + connect(d, &QPlatformAudioSink::stateChanged, this, [this](QAudio::State state) { + // if the signal has been emitted from another thread, + // the state may be already changed by main one + if (state == d->state()) + emit stateChanged(state); + }); else qWarning() << ("No audio device detected"); } |