From be919fd68a844a2e7e0d15c70fc5ccacce8d4edc Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Fri, 4 May 2018 09:06:19 +0200 Subject: 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 Reviewed-by: Christian Stromme --- src/multimedia/audio/qsoundeffect_qaudio_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/multimedia') 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); } -- cgit v1.2.3