diff options
author | Piotr Srebrny <piotr.srebrny@qt.io> | 2022-08-24 15:13:09 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-25 17:03:30 +0000 |
commit | ca3f7d464f8a8a86083ff083d2e2689db9414999 (patch) | |
tree | 63eaf20c4ac1d700f202ce35bd0ff7e7fb8d77a9 | |
parent | 923b25ead47244d3c2130eb5306b5dc9f9dc112b (diff) | |
download | qtmultimedia-ca3f7d464f8a8a86083ff083d2e2689db9414999.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)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/windows/qwindowsaudiosink.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/multimedia/windows/qwindowsaudiosink.cpp b/src/multimedia/windows/qwindowsaudiosink.cpp index 091ffaf9e..b16b8a3b8 100644 --- a/src/multimedia/windows/qwindowsaudiosink.cpp +++ b/src/multimedia/windows/qwindowsaudiosink.cpp @@ -164,6 +164,9 @@ void QWindowsAudioSink::start(QIODevice* device) if (deviceState != QAudio::StoppedState) close(); + if (device == nullptr) + return; + if (!open()) { errorState = QAudio::OpenError; emit errorChanged(QAudio::OpenError); @@ -175,7 +178,7 @@ void QWindowsAudioSink::start(QIODevice* device) connect(device, &QIODevice::readyRead, this, &QWindowsAudioSink::pullSource); m_timer.disconnect(); m_timer.callOnTimeout(this, &QWindowsAudioSink::pullSource); - m_timer.start(0); + pullSource(); } qint64 QWindowsAudioSink::push(const char *data, qint64 len) |