aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-04 23:45:27 -0700
committerChris Robinson <[email protected]>2019-05-04 23:45:27 -0700
commit0c09c8378bc2c6a300177bcb417b7bf534ac4bf4 (patch)
treef8dc690178cd949c6a2ee48d506532caa6ec65bc /Alc
parent42dfefbb0e2d9564e977d392a651184b1ac8d490 (diff)
Set the device channel order from PulseAudio's channel map
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/pulseaudio.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index d8e1c267..f5483818 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -213,6 +213,74 @@ constexpr pa_channel_map MonoChanMap{
}
};
+size_t ChannelFromPulse(pa_channel_position_t chan)
+{
+ switch(chan)
+ {
+ case PA_CHANNEL_POSITION_INVALID: break;
+ case PA_CHANNEL_POSITION_MONO: return FrontCenter;
+ case PA_CHANNEL_POSITION_FRONT_LEFT: return FrontLeft;
+ case PA_CHANNEL_POSITION_FRONT_RIGHT: return FrontRight;
+ case PA_CHANNEL_POSITION_FRONT_CENTER: return FrontCenter;
+ case PA_CHANNEL_POSITION_REAR_CENTER: return BackCenter;
+ case PA_CHANNEL_POSITION_REAR_LEFT: return BackLeft;
+ case PA_CHANNEL_POSITION_REAR_RIGHT: return BackRight;
+ case PA_CHANNEL_POSITION_LFE: return LFE;
+ case PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: break;
+ case PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: break;
+ case PA_CHANNEL_POSITION_SIDE_LEFT: return SideLeft;
+ case PA_CHANNEL_POSITION_SIDE_RIGHT: return SideRight;
+ case PA_CHANNEL_POSITION_AUX0: return Aux0;
+ case PA_CHANNEL_POSITION_AUX1: return Aux1;
+ case PA_CHANNEL_POSITION_AUX2: return Aux2;
+ case PA_CHANNEL_POSITION_AUX3: return Aux3;
+ case PA_CHANNEL_POSITION_AUX4: return Aux4;
+ case PA_CHANNEL_POSITION_AUX5: return Aux5;
+ case PA_CHANNEL_POSITION_AUX6: return Aux6;
+ case PA_CHANNEL_POSITION_AUX7: return Aux7;
+ case PA_CHANNEL_POSITION_AUX8: return Aux8;
+ case PA_CHANNEL_POSITION_AUX9: return Aux9;
+ case PA_CHANNEL_POSITION_AUX10: return Aux10;
+ case PA_CHANNEL_POSITION_AUX11: return Aux11;
+ case PA_CHANNEL_POSITION_AUX12: return Aux12;
+ case PA_CHANNEL_POSITION_AUX13: return Aux13;
+ case PA_CHANNEL_POSITION_AUX14: return Aux14;
+ case PA_CHANNEL_POSITION_AUX15: return Aux15;
+ case PA_CHANNEL_POSITION_AUX16: break;
+ case PA_CHANNEL_POSITION_AUX17: break;
+ case PA_CHANNEL_POSITION_AUX18: break;
+ case PA_CHANNEL_POSITION_AUX19: break;
+ case PA_CHANNEL_POSITION_AUX20: break;
+ case PA_CHANNEL_POSITION_AUX21: break;
+ case PA_CHANNEL_POSITION_AUX22: break;
+ case PA_CHANNEL_POSITION_AUX23: break;
+ case PA_CHANNEL_POSITION_AUX24: break;
+ case PA_CHANNEL_POSITION_AUX25: break;
+ case PA_CHANNEL_POSITION_AUX26: break;
+ case PA_CHANNEL_POSITION_AUX27: break;
+ case PA_CHANNEL_POSITION_AUX28: break;
+ case PA_CHANNEL_POSITION_AUX29: break;
+ case PA_CHANNEL_POSITION_AUX30: break;
+ case PA_CHANNEL_POSITION_AUX31: break;
+ case PA_CHANNEL_POSITION_TOP_CENTER: break;
+ case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return UpperFrontLeft;
+ case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return UpperFrontRight;
+ case PA_CHANNEL_POSITION_TOP_FRONT_CENTER: break;
+ case PA_CHANNEL_POSITION_TOP_REAR_LEFT: return UpperBackLeft;
+ case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return UpperBackRight;
+ case PA_CHANNEL_POSITION_TOP_REAR_CENTER: break;
+ case PA_CHANNEL_POSITION_MAX: break;
+ }
+ throw al::backend_exception{ALC_INVALID_VALUE, "Unexpected channel enum %d", chan};
+}
+
+void SetChannelOrderFromMap(ALCdevice *device, const pa_channel_map &chanmap)
+{
+ device->RealOut.ChannelIndex.fill(-1);
+ for(int i{0};i < chanmap.channels;++i)
+ device->RealOut.ChannelIndex[ChannelFromPulse(chanmap.map[i])] = i;
+}
+
/* *grumble* Don't use enums for bitflags. */
inline pa_stream_flags_t operator|(pa_stream_flags_t lhs, pa_stream_flags_t rhs)
@@ -874,7 +942,7 @@ ALCboolean PulsePlayback::reset()
chanmap = X71ChanMap;
break;
}
- SetDefaultWFXChannelOrder(mDevice);
+ SetChannelOrderFromMap(mDevice, chanmap);
switch(mDevice->FmtType)
{
@@ -1176,6 +1244,7 @@ ALCenum PulseCapture::open(const ALCchar *name)
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
DevFmtChannelsString(mDevice->FmtChans)};
}
+ SetChannelOrderFromMap(mDevice, chanmap);
switch(mDevice->FmtType)
{