- for (iChannel = 0; iChannel < pDescriptorPlayback->channels; ++iChannel) {
- pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
+ /*
+ Bug in PipeWire. There have been reports that PipeWire is returning AUX channels when reporting
+ the channel map. To somewhat workaround this, I'm hacking in a hard coded channel map for mono
+ and stereo. In this case it should be safe to assume mono = MONO and stereo = LEFT/RIGHT. For
+ all other channel counts we need to just put up with whatever PipeWire reports and hope it gets
+ fixed sooner than later. I might remove this hack later.
+ */
+ if (pDescriptorPlayback->channels > 2) {
+ pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
+ if (pActualCMap != NULL) {
+ cmap = *pActualCMap;
+ }
+
+ for (iChannel = 0; iChannel < pDescriptorPlayback->channels; ++iChannel) {
+ pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
+ }
+ } else {
+ /* Hack for mono and stereo. */
+ if (pDescriptorPlayback->channels == 1) {
+ pDescriptorPlayback->channelMap[0] = MA_CHANNEL_MONO;
+ } else if (pDescriptorPlayback->channels == 2) {
+ pDescriptorPlayback->channelMap[0] = MA_CHANNEL_FRONT_LEFT;
+ pDescriptorPlayback->channelMap[1] = MA_CHANNEL_FRONT_RIGHT;
+ } else {
+ MA_ASSERT(MA_FALSE); /* Should never hit this. */
+ }