summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qsoundeffect_qaudio_p.cpp')
-rw-r--r--src/multimedia/audio/qsoundeffect_qaudio_p.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
index 73f1d5cfd..3f315fa28 100644
--- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QSampleCache, sampleCache)
-QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
+QSoundEffectPrivate::QSoundEffectPrivate(QObject *parent):
QObject(parent),
d(new PrivateSoundSource(this))
{
@@ -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);
@@ -302,7 +309,7 @@ void QSoundEffectPrivate::setCategory(const QString &category)
}
}
-PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate* s):
+PrivateSoundSource::PrivateSoundSource(QSoundEffectPrivate *s):
QIODevice(s)
{
soundeffect = s;
@@ -354,7 +361,7 @@ void PrivateSoundSource::stateChanged(QAudio::State state)
emit soundeffect->stop();
}
-qint64 PrivateSoundSource::readData( char* data, qint64 len)
+qint64 PrivateSoundSource::readData(char *data, qint64 len)
{
if ((m_runningCount > 0 || m_runningCount == QSoundEffect::Infinite) && m_playing) {
@@ -428,7 +435,7 @@ qint64 PrivateSoundSource::readData( char* data, qint64 len)
return 0;
}
-qint64 PrivateSoundSource::writeData(const char* data, qint64 len)
+qint64 PrivateSoundSource::writeData(const char *data, qint64 len)
{
Q_UNUSED(data)
Q_UNUSED(len)