2

(Under Qt 4.8.2 4.8.3, Qt MultimediaKit 1.2, Linux (edit: Kubuntu 12.10, qt from packages)

I have a QAudioOutput which is fed with data every 20ms. If I stop it via ::stop(), stateChanged() signal is emitted by it that it's been stopped (immediately; its thread is the same as the controlling thread. The symptoms exist even if they are both in the GUI thread or both in another).

I delete it then, but once or twice out of every 10 tries it crashes with the following backtrace:

#0  0x00007fab18000148 in ?? ()
#1  0x00007fab47b51eef in QMetaObject::activate (sender=0x7fab1800b060, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fab2b0e8850) at kernel/qobject.cpp:3541
#2  0x00007fab4aa46eae in QAbstractAudioOutput::stateChanged(QAudio::State) () from /usr/lib/x86_64-linux-gnu/libQtMultimediaKit.so.1
#3  0x00007fab2b0f38c8 in ?? () from /usr/lib/x86_64-linux-gnu/qt4/plugins/audio/libqtmedia_pulse.so
#4  0x00007fab2b0f33ad in ?? () from /usr/lib/x86_64-linux-gnu/qt4/plugins/audio/libqtmedia_pulse.so
#5  0x00007fab420a475b in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#6  0x00007fab3b1749fd in pa_pdispatch_run () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-2.1.so
#7  0x00007fab42086e1d in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#8  0x00007fab3b178a2b in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-2.1.so
#9  0x00007fab4209a374 in pa_mainloop_dispatch () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#10 0x00007fab4209a725 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#11 0x00007fab4209a7d0 in pa_mainloop_run () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#12 0x00007fab420a8b1f in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#13 0x00007fab3b186543 in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-2.1.so
#14 0x00007fab477aee9a in start_thread (arg=0x7fab2b0e9700) at pthread_create.c:308
#15 0x00007fab46cc6cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#16 0x0000000000000000 in ?? ()

This seems to be some kind of thread of pulse which is still trying to access the old QAudioOutput (with no luck). Via signal/slots, this should be thread safe ( according to QObject::~QObject, I did not do anything wrong by deleting it from the controlling thread (which was called by an external signal, not via QAudioOutput's signal by the way).

The crash occurs even if I call deleteLater(). Am I doing something wrong, or this could be a bug in Qt? If it's a bug, my theory is that it doesn't get any more data, which causes an Idle state with BufferUnderflow error, which comes from Pulse without proper synchronization. As a workaround I'll stop feeding it and wait for Idle before stopping, but I still don't understand how could this crash happen.

Edit: working example (change a simple gui app)

In the real application a VoIP call takes place; most of the time it closes OK, but sometimes it crashes. The following example tries to simulate a single 20ms packet play (with audio init before, audio stop after; we wait for 22ms to make the buffer underflow/state change to idle, it seems to me that this is the key. The crash itself does not occur because of the low timing values (it just helps to crash quicker), in the production code it can crash with real calls. )

mainwindow.h mainwindow.cpp

append the project file with:

QT += mobility
MOBILITY += multimedia
CONFIG += mobility
grizzancs
  • 397
  • 3
  • 11

0 Answers0