QtMultimedia 6 - QPulseAudioSink how to set stream name?
-
pa_stream_new_with_proplistfunction (https://freedesktop.org/software/pulseaudio/doxygen/stream_8h.html#a5bd70e309f09679753499fa198713672) acceptsnameargument, which is used to distinguish audio streams.
This function is called fromQPulseAudioSink::open():m_stream = pa_stream_new_with_proplist(pulseEngine->context(), m_streamName.constData(), &m_spec, &channel_map, propList);But the problem is
m_streamNameis always initilized like this (in the sameopen() method):if (m_streamName.isNull()) m_streamName = QStringLiteral("QtmPulseStream-%1-%2").arg(::getpid()).arg(quintptr(this)).toUtf8();This makes the stream name a random string every app launch ("QtmPulseStream-...."), making it impossible to remember which output device to use (for example, there's such setting in KDE, but random stream name makes this setting single-shot and thus useless).
I can probably add output device setting in my app, or inherit QAudioSink and hack it somehow, but this is not the question here. The question is how to set
m_streamName? Or is it designed to be random like this?This problem does not exists in Qt5+gstreamer, there stream name is always equal to application name and the association app->device is preserved between restarts. No idea how it happens b/c the code for
QPulseAudioSinkis identical.In Qt6 when using
QT_MEDIA_BACKEND=gstreamerthe behavior is slightly different: I see app name in as the stream name in KDE audio settings, but it still does not remember the association app-to-device, so it seems like there's randomness still. Also, no idea how backend changes audio sink behavior, does ffmpeg or gtreamer override stream name afterwards? -
N Nhan Nguyen moved this topic from General and Desktop on