From 83542fd6b134b1fb70b085e62819c3e742a9e31f Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Mon, 15 Jan 2018 12:16:37 +0100 Subject: QSoundEffect: Release QAudioOutput when new source url applied When sample is ready QAudioOutput is created with sample's format. In case when new source url is applied old format is reused in QAudioOutput instance which might lead incorrect playback. Task-number: QTBUG-54262 Change-Id: I84af167412cb53726593a3bfd4193fc7cd71f332 Reviewed-by: Andy Shaw Reviewed-by: Christian Stromme --- src/multimedia/audio/qsoundeffect_qaudio_p.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp index 388f84d91..3f315fa28 100644 --- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp +++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp @@ -132,6 +132,13 @@ void QSoundEffectPrivate::setSource(const QUrl &url) d->m_sample = nullptr; } + if (d->m_audioOutput) { + disconnect(d->m_audioOutput, &QAudioOutput::stateChanged, d, &PrivateSoundSource::stateChanged); + d->m_audioOutput->stop(); + d->m_audioOutput->deleteLater(); + d->m_audioOutput = nullptr; + } + setStatus(QSoundEffect::Loading); d->m_sample = sampleCache()->requestSample(url); connect(d->m_sample, &QSample::error, d, &PrivateSoundSource::decoderError); -- cgit v1.2.3