I write a helloworld of QAudioOutput by QT5.15.2 like this:
`
#include <QCoreApplication>
#include <QAudioOutput>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QAudioOutput *m_pAudioOutput = nullptr;
QIODevice *m_pAudioDevice = nullptr;
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (info.deviceName().isEmpty())
{
qInfo() << "No default auido output device available!";
return 0;
}
return a.exec();
}
` Then run it on Debian 10.9 x64, and gdb attach to the process, show threads:
`
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f62b082d8c0 (LWP 12787) "HelloQtAudio" 0x00007f62b2753589 in __GI___poll (fds=0x5562098188a0, nfds=1,
timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
2 Thread 0x7f62b0513700 (LWP 12788) "threaded-ml" 0x00007f62b2753589 in __GI___poll (fds=0x7f62a4007030, nfds=3,
timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
(gdb) thread 2
[Switching to thread 2 (Thread 0x7f62b0513700 (LWP 12788))]
#0 0x00007f62b2753589 in __GI___poll (fds=0x7f62a4007030, nfds=3, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
29 in ../sysdeps/unix/sysv/linux/poll.c
(gdb) bt
#0 0x00007f62b2753589 in __GI___poll (fds=0x7f62a4007030, nfds=3, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007f62b263f131 in ?? () from /lib/x86_64-linux-gnu/libpulse.so.0
#2 0x00007f62b26309a0 in pa_mainloop_poll () from /lib/x86_64-linux-gnu/libpulse.so.0
#3 0x00007f62b2630fee in pa_mainloop_iterate () from /lib/x86_64-linux-gnu/libpulse.so.0
#4 0x00007f62b26310a0 in pa_mainloop_run () from /lib/x86_64-linux-gnu/libpulse.so.0
#5 0x00007f62b263f079 in ?? () from /lib/x86_64-linux-gnu/libpulse.so.0
#6 0x00007f62b22d3468 in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-12.2.so
#7 0x00007f62b2b4ffa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
#8 0x00007f62b275deff in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)
`
I do nothing in my main, why does QT starts a pa_mainloop_run thread? Is it usable? Then if call m_pAudioOutput->start(), it start another same thread, does it means a thread pool increasing workers?
I'm trying to resolve an alsa underrun bug in audio playback.