aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gibson <[email protected]>2020-06-07 17:18:07 +0200
committerDaniel Gibson <[email protected]>2020-06-07 17:22:51 +0200
commit5cffe7e50a2885d9b392c15f2cd3941cac49692c (patch)
tree24dbe925970f15ccbe6bf3a31d694455673d9043
parent70d345bbf20186f6765442060f02db531a5ad7a7 (diff)
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.
-rw-r--r--alc/backends/sndio.cpp34
1 files 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;