From c7180435887c55a76aca2948a76327d0d57a5645 Mon Sep 17 00:00:00 2001 From: Lev Zelenskiy Date: Fri, 20 Apr 2012 17:02:35 +1000 Subject: Do not try to complete flush operation if stream has changed. There is a problem when sound effect already has a sound loaded and we try to load new sound with setSource(). When sampleReady() is called between emptyStream() and emptyComplete() it unloads the current stream and creates a new stream. As a result pulse audio crashed in emptyComplete() while calling pa_operation_unref(pa_stream_cork( m_pulseStream, 1, stream_cork_callback, m_ref->getRef())) with the new m_pulseStream. Change-Id: Idff4fe6037d3f3f116734dc0facabaafa3db14a2 Reviewed-by: Michael Goddard Reviewed-by: Ling Hu --- src/multimedia/audio/qsoundeffect_pulse_p.cpp | 12 +++++++++--- src/multimedia/audio/qsoundeffect_pulse_p.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/multimedia') diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp index 3b9278c7d..8cc49004a 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp @@ -628,11 +628,17 @@ void QSoundEffectPrivate::emptyStream() pa_operation_unref(pa_stream_flush(m_pulseStream, stream_flush_callback, m_ref->getRef())); } -void QSoundEffectPrivate::emptyComplete() +void QSoundEffectPrivate::emptyComplete(void *stream) { PulseDaemonLocker locker; +#ifdef QT_PA_DEBUG + qDebug() << this << "emptyComplete"; +#endif + m_emptying = false; - pa_operation_unref(pa_stream_cork(m_pulseStream, 1, stream_cork_callback, m_ref->getRef())); + + if ((pa_stream *)stream == m_pulseStream) + pa_operation_unref(pa_stream_cork(m_pulseStream, 1, stream_cork_callback, m_ref->getRef())); } void QSoundEffectPrivate::sampleReady() @@ -1122,7 +1128,7 @@ void QSoundEffectPrivate::stream_flush_callback(pa_stream *s, int success, void #ifdef QT_PA_DEBUG qDebug() << self << "stream_flush_callback"; #endif - QMetaObject::invokeMethod(self, "emptyComplete", Qt::QueuedConnection); + QMetaObject::invokeMethod(self, "emptyComplete", Qt::QueuedConnection, Q_ARG(void*, s)); } void QSoundEffectPrivate::stream_write_done_callback(void *p) diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h index 6c7202c24..1d5aa9305 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.h +++ b/src/multimedia/audio/qsoundeffect_pulse_p.h @@ -118,7 +118,7 @@ private Q_SLOTS: void underRun(); void prepare(); void streamReady(); - void emptyComplete(); + void emptyComplete(void *stream); void updateVolume(); void updateMuted(); -- cgit v1.2.3