diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2018-11-12 11:00:54 +0100 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2018-12-03 16:34:28 +0000 |
commit | 6dc19a0b10444f33acb1196f1ff85301cb29faea (patch) | |
tree | 9022d109c1d3c649995c24cd7532603b2997e810 | |
parent | 4aa4bbf4ad701adcb07f20b40ed190a80f51cc5b (diff) | |
download | qtmultimedia-6dc19a0b10444f33acb1196f1ff85301cb29faea.tar.gz |
PulseAudio: Introduce QT_PA_CHANNEL_MAP for QAudioOutput
Introduced QT_PA_CHANNEL_MAP env var to define one of channel mapping definitions:
ALSA = PA_CHANNEL_MAP_ALSA
AUX = PA_CHANNEL_MAP_AUX
WAVEEX = PA_CHANNEL_MAP_WAVEEX
OSS = PA_CHANNEL_MAP_OSS
and PA_CHANNEL_MAP_DEFAULT as default
Usage QT_PA_CHANNEL_MAP=AUX ./app
Also fixed a crash when the number of the channels is too high.
Task-number: QTBUG-71710
Change-Id: I45f7f7499cb7db218d5dc7d2eb7764c835abf8f7
Reviewed-by: Otto Ryynänen <otto.ryynanen@qt.io>
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r-- | src/plugins/pulseaudio/qaudiooutput_pulse.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp index ea7a2be0c..b4bd1c55c 100644 --- a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp +++ b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp @@ -310,7 +310,34 @@ bool QPulseAudioOutput::open() if (!m_category.isNull()) pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, m_category.toLatin1().constData()); - m_stream = pa_stream_new_with_proplist(pulseEngine->context(), m_streamName.constData(), &m_spec, 0, propList); + static const auto mapName = qEnvironmentVariable("QT_PA_CHANNEL_MAP"); + pa_channel_map_def_t mapDef = PA_CHANNEL_MAP_DEFAULT; + if (mapName == QLatin1String("ALSA")) + mapDef = PA_CHANNEL_MAP_ALSA; + else if (mapName == QLatin1String("AUX")) + mapDef = PA_CHANNEL_MAP_AUX; + else if (mapName == QLatin1String("WAVEEX")) + mapDef = PA_CHANNEL_MAP_WAVEEX; + else if (mapName == QLatin1String("OSS")) + mapDef = PA_CHANNEL_MAP_OSS; + else if (!mapName.isEmpty()) + qWarning() << "Unknown pulse audio channel mapping definition:" << mapName; + + pa_channel_map m; + auto channelMap = pa_channel_map_init_extend(&m, m_spec.channels, mapDef); + if (!channelMap) + qWarning() << "QAudioOutput: pa_channel_map_init_extend() Could not initialize channel map"; + + m_stream = pa_stream_new_with_proplist(pulseEngine->context(), m_streamName.constData(), &m_spec, channelMap, propList); + if (!m_stream) { + qWarning() << "QAudioOutput: pa_stream_new_with_proplist() failed!"; + pulseEngine->unlock(); + setError(QAudio::OpenError); + setState(QAudio::StoppedState); + emit stateChanged(m_deviceState); + return false; + } + pa_proplist_free(propList); pa_stream_set_state_callback(m_stream, outputStreamStateCallback, this); |