From 359b0e2b4dd6524742ab4956e71b1b6d42e0cb0f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 10 Nov 2024 15:41:22 -0800 Subject: [PATCH] Recognize more channel configurations from SDL --- alc/backends/sdl2.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp index f7fc0e45..04131c4b 100644 --- a/alc/backends/sdl2.cpp +++ b/alc/backends/sdl2.cpp @@ -176,13 +176,22 @@ bool Sdl2Backend::reset() if(have.channels != mDevice->channelsFromFmt()) { - if(have.channels < 1) - throw al::backend_exception{al::backend_error::DeviceError, - "Unhandled SDL channel count: %d", int{have.channels}}; - if(have.channels == 1) + /* SDL guarantees these layouts for the given channel count. */ + if(have.channels == 8) + mDevice->FmtChans = DevFmtX71; + else if(have.channels == 7) + mDevice->FmtChans = DevFmtX61; + else if(have.channels == 6) + mDevice->FmtChans = DevFmtX51; + else if(have.channels == 4) + mDevice->FmtChans = DevFmtQuad; + else if(have.channels >= 2) + mDevice->FmtChans = DevFmtStereo; + else if(have.channels == 1) mDevice->FmtChans = DevFmtMono; else - mDevice->FmtChans = DevFmtStereo; + throw al::backend_exception{al::backend_error::DeviceError, + "Unhandled SDL channel count: %d", int{have.channels}}; mDevice->mAmbiOrder = 0; } -- 2.11.4.GIT