QAudioOutput constructor hangs in PyQt6

ekhumoro ekhumoro at gmx.com
Sat Apr 11 21:44:16 BST 2026


On 11/04/2026 18:49, ekhumoro wrote:
> On 11/04/2026 17:27, Phil Thompson wrote:
>> The attached is a version of your Python code modified so that it *is* the equivalent of the C++ code. It does not hang.
>>
>> Your original code enters the event loop unconditionally, ie. when there is no audio to play
> 
> Actually, it doesn't enter the event loop *at all*, because it hangs when creating the audio output object. Your version 
> of the code also hangs on my system, for exactly the same reason. The critical section is this:
> 
>      qDebug('creating audio output...')
>      audio = QAudioOutput()              # <-- hangs here
>      qDebug('audio output created')
> 
> Given the way `qInstallMessageHandler` works, I assume PyQt6 must doing *something* different - otherwise it's hard to 
> understand why the C++ example never hangs on my system. The *only* difference seems to be the handling of that specific 
> warning message.

After some further investigation, I discovered that the specific warning message that seems to cause the hang comes from 
within Qt6 itself, as part of its pipewire support. The debug print is in 
qtmultimedia/src/multimedia/pipewire/qpipewire_spa_pod_parser_support_p.h, in the spaVisitChoice function around line 140:

     qWarning() << "spaVisitChoice: parse error" << pod;

The pod variable is a complex nested struct type defined by pipewire (see: https://docs.pipewire.org/page_spa_pod.html). 
Qt6 implements a special QDebug operator to handle this type via a QtSpaDebugContext, which can be found in 
qtmultimedia/src/multimedia/pipewire/qpipewire_support.cpp. Is there something here which could cause PyQt6 problems?

Most Linux systems seem to use pipewire these days (rather than pulseaudio), and Qt6 recommends it (see: 
https://doc.qt.io/qt-6/qtmultimedia-linux.html). Presumably there must be some other people using pipewire on Linux who 
should be able to reproduce my PyQt6 hang behaviour, although it's not clear to me yet what's causing the parse error.




More information about the PyQt mailing list