seg fault for qt5+pulseaudio
Solved
Mobile and Embedded
-
Hi,
I'm trying to test the multimedia support for Qt5 with pulseaudio backend. I'm running a custom buildroot environment on an RPi3.
I have checked the following are working:- qt5 - alsa (aplay / arecord) - pulseaudio (paplay / parecord)
This is the code snippet, as found in the docs:
QFile file(filename); file.open(QIODevice::ReadOnly); qDebug() << file.size(); QAudioFormat format; format.setSampleRate(8000); format.setChannelCount(2); format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::SignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); if (!info.isFormatSupported(format)) { qWarning() << "Raw audio format not supported by backend, cannot play audio."; return; } m_audio = new QAudioOutput(format, this); m_audio->start(&file);
The file is correctly opened, no sounds is emitted but after few seconds the application crashes due to segmentation fault.
The debugger shows some disassemled code and the stack calls on thead #1 are these:1 QIODevice::read(char *, long long) 0x75efcf48 2 QPulseAudioOutput::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) 0x724cb79c
What should I do understand the cause of the seg fault?
-
This line:
m_audio->start(&file);
Is giving
m_audio
a pointer to the (looks-to-be) localfile
variable, which won't be valid oncefile
goes out of scope.Cheers.