summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Srebrny <piotr.srebrny@qt.io>2022-08-24 15:13:09 +0200
committerPiotr Srebrny <piotr.srebrny@qt.io>2022-09-02 12:35:14 +0200
commit34958f933982bd71ffbe9ea367fedf3c6d95709f (patch)
treedb7ab86a71f5b2a5721a44104125c91cedbf6836
parent2ab2bc48f66103977a925b2bf5e2d77aceecd3e7 (diff)
downloadqtmultimedia-34958f933982bd71ffbe9ea367fedf3c6d95709f.tar.gz
Call pullSource() immediately when starting QAudioSink
When executing the first pullSource() on the timer timeout, the caller of start() could call close() before pullSource(). Since pullSource updates the state the close() would just return and the timer would run pullSource() soon after. Calling pullSource() avoids this problem as it immediatelly updates the state. Change-Id: Ib6dc2bb0cb15aa4eaa03e384615e57afada0eae6 Reviewed-by: André de la Rocha <andre.rocha@qt.io> (cherry picked from commit e6f57072dfa59d0dec9e1adfc9a5fa60564468d8)
-rw-r--r--src/multimedia/platform/windows/audio/qwindowsaudiosink.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/multimedia/platform/windows/audio/qwindowsaudiosink.cpp b/src/multimedia/platform/windows/audio/qwindowsaudiosink.cpp
index 046a91ab0..39625ed1b 100644
--- a/src/multimedia/platform/windows/audio/qwindowsaudiosink.cpp
+++ b/src/multimedia/platform/windows/audio/qwindowsaudiosink.cpp
@@ -200,6 +200,9 @@ void QWindowsAudioSink::start(QIODevice* device)
if (deviceState != QAudio::StoppedState)
close();
+ if (device == nullptr)
+ return;
+
if (!open()) {
errorState = QAudio::OpenError;
emit errorChanged(QAudio::OpenError);
@@ -210,7 +213,7 @@ void QWindowsAudioSink::start(QIODevice* device)
m_timer.disconnect();
m_timer.callOnTimeout(this, &QWindowsAudioSink::pullSource);
- m_timer.start(0);
+ pullSource();
}
qint64 QWindowsAudioSink::push(const char *data, qint64 len)