From 5cffe7e50a2885d9b392c15f2cd3941cac49692c Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 7 Jun 2020 17:18:07 +0200 Subject: sndio: Support more than 2 channels So far the sndio backend only supports Mono and Stereo, but sndio supports up to 16 channels (64 in their current git code). This adds support for all the openal-soft formats (DevFmt*). I tested this on Linux with 5.1 surround speakers. --- alc/backends/sndio.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index d34a0144..f51f508f 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -127,7 +127,21 @@ bool SndioPlayback::reset() sio_initpar(&par); par.rate = mDevice->Frequency; - par.pchan = ((mDevice->FmtChans != DevFmtMono) ? 2 : 1); + switch(mDevice->FmtChans) + { + case DevFmtMono : par.pchan = 1; break; + case DevFmtQuad : par.pchan = 4; break; + case DevFmtX51Rear: // fall-through - "Similar to 5.1, except using rear channels instead of sides" + case DevFmtX51 : par.pchan = 6; break; + case DevFmtX61 : par.pchan = 7; break; + case DevFmtX71 : par.pchan = 8; break; + + case DevFmtStereo : // fall-through + default: // fall back to stereo for all unknown formats and Ambi3D + mDevice->FmtChans = DevFmtStereo; + par.pchan = 2; + break; + } switch(mDevice->FmtType) { @@ -176,7 +190,23 @@ bool SndioPlayback::reset() } mDevice->Frequency = par.rate; - mDevice->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo); + + switch(par.pchan) + { + case 1: mDevice->FmtChans = DevFmtMono; break; + case 2: mDevice->FmtChans = DevFmtStereo; break; + case 4: mDevice->FmtChans = DevFmtQuad; break; + case 6: + if(mDevice->FmtChans != DevFmtX51Rear) // if it's already DevFmtX51Rear no change is needed + mDevice->FmtChans = DevFmtX51; + break; + case 7: mDevice->FmtChans = DevFmtX61; break; + case 8: mDevice->FmtChans = DevFmtX71; break; + + default: + ERR("Unexpected number of channels: %d\n", par.pchan); + return ALC_FALSE; + } if(par.bits == 8 && par.sig == 1) mDevice->FmtType = DevFmtByte; -- cgit v1.2.3