diff --git a/miniaudio.h b/miniaudio.h index fb0a3e5a..1912d083 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -32658,6 +32658,7 @@ static ma_result ma_device_init_internal__pipewire(ma_device* pDevice, ma_contex struct ma_pw_properties* pProperties; const struct ma_pw_stream_events* pStreamEvents; enum ma_spa_audio_format formatPA; + ma_uint32 channels; struct ma_spa_pod_audio_info_raw podAudioInfo; const struct ma_spa_pod* pConnectionParameters[1]; enum ma_pw_stream_flags streamFlags; @@ -32710,7 +32711,20 @@ static ma_result ma_device_init_internal__pipewire(ma_device* pDevice, ma_contex } } - podAudioInfo = ma_spa_pod_audio_info_raw_init(formatPA, pDescriptor->channels, pDescriptor->sampleRate); + /* + An annoying detail here. When a single channel is requested it will be output to the FL channel and not distributed + to additional channels. This means with headphones the sound will only come out of the left side. But then there are + times when an app would literally want to output to only a single channel. + + The way I'm going to deal with this is when a single channel is requested and the `MA_CHANNEL_MONO` channel position + is explicitly listed in the channel map, we'll request the "native" channel count. + */ + channels = pDescriptor->channels; + if (channels == 1 && (pDescriptor->channelMap[0] == MA_CHANNEL_NONE || pDescriptor->channelMap[0] == MA_CHANNEL_MONO)) { + channels = 0; + } + + podAudioInfo = ma_spa_pod_audio_info_raw_init(formatPA, channels, pDescriptor->sampleRate); pConnectionParameters[0] = (struct ma_spa_pod*)&podAudioInfo;