diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2018-05-04 09:06:19 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2018-11-05 12:47:45 +0000 |
commit | be919fd68a844a2e7e0d15c70fc5ccacce8d4edc (patch) | |
tree | 575f75757f2517bae3d1e6c7f4890b2b049c6e2c /src | |
parent | 630738f9ef1ba7467c3c280a1cb64471c37d62d1 (diff) |
Alsa: Do not open device twice in QSoundEffect
When either QSoundEffect::loadedChanged or QSoundEffect::statusChanged is emitted
QSoundEffect::play() can be called which results to call QAudioOutput::start() twice.
Added a fix to call QAudioOutput::start() only if QAudioOutput::state() is QAudio::StoppedState.
Flow trace:
1. PrivateSoundSource::sampleReady()
2. QSoundEffectPrivate::setStatus(QSoundEffect::Ready)
and emits statusChanged() or loadedChanged()
3. If there is a connection to QSoundEffect::loadedChanged/statusChanged
and QSoundEffect::play() is called there.
4. QSoundEffect::play() calls QAudioOutput::start() because sample is ready
5. QAudioOutput::start() is called again within PrivateSoundSource::sampleReady()
when QSoundEffectPrivate::setStatus exited.
Change-Id: I7ad8e9126b6006e1972356c80a7fd2e5c6a5ea04
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/audio/qsoundeffect_qaudio_p.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp index 3f315fa28..d7a19eeec 100644 --- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp +++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp @@ -338,7 +338,7 @@ void PrivateSoundSource::sampleReady() m_sampleReady = true; soundeffect->setStatus(QSoundEffect::Ready); - if (m_playing) + if (m_playing && m_audioOutput->state() == QAudio::StoppedState) m_audioOutput->start(this); } |