aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/alsa.cpp2
-rw-r--r--alc/backends/base.cpp121
-rw-r--r--alc/backends/base.h6
-rw-r--r--alc/backends/coreaudio.cpp2
-rw-r--r--alc/backends/dsound.cpp4
-rw-r--r--alc/backends/jack.cpp2
-rw-r--r--alc/backends/loopback.cpp2
-rw-r--r--alc/backends/null.cpp2
-rw-r--r--alc/backends/oboe.cpp2
-rw-r--r--alc/backends/opensl.cpp2
-rw-r--r--alc/backends/oss.cpp2
-rw-r--r--alc/backends/portaudio.cpp2
-rw-r--r--alc/backends/sdl2.cpp2
-rw-r--r--alc/backends/sndio.cpp4
-rw-r--r--alc/backends/solaris.cpp2
-rw-r--r--alc/backends/wasapi.cpp2
-rw-r--r--alc/backends/wave.cpp2
-rw-r--r--alc/backends/winmm.cpp2
18 files changed, 145 insertions, 18 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index 993a4d2e..2259c46c 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -787,7 +787,7 @@ bool AlsaPlayback::reset()
mDevice->UpdateSize = static_cast<ALuint>(periodSizeInFrames);
mDevice->Frequency = rate;
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
return true;
}
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index 01cc5213..c0783f86 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -44,3 +44,124 @@ ClockLatency BackendBase::getClockLatency()
return ret;
}
+
+void BackendBase::setDefaultWFXChannelOrder()
+{
+ mDevice->RealOut.ChannelIndex.fill(INVALID_CHANNEL_INDEX);
+
+ switch(mDevice->FmtChans)
+ {
+ case DevFmtMono:
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 0;
+ break;
+ case DevFmtStereo:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ break;
+ case DevFmtQuad:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[BackLeft] = 2;
+ mDevice->RealOut.ChannelIndex[BackRight] = 3;
+ break;
+ case DevFmtX51:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 2;
+ mDevice->RealOut.ChannelIndex[LFE] = 3;
+ mDevice->RealOut.ChannelIndex[SideLeft] = 4;
+ mDevice->RealOut.ChannelIndex[SideRight] = 5;
+ break;
+ case DevFmtX51Rear:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 2;
+ mDevice->RealOut.ChannelIndex[LFE] = 3;
+ mDevice->RealOut.ChannelIndex[BackLeft] = 4;
+ mDevice->RealOut.ChannelIndex[BackRight] = 5;
+ break;
+ case DevFmtX61:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 2;
+ mDevice->RealOut.ChannelIndex[LFE] = 3;
+ mDevice->RealOut.ChannelIndex[BackCenter] = 4;
+ mDevice->RealOut.ChannelIndex[SideLeft] = 5;
+ mDevice->RealOut.ChannelIndex[SideRight] = 6;
+ break;
+ case DevFmtX71:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 2;
+ mDevice->RealOut.ChannelIndex[LFE] = 3;
+ mDevice->RealOut.ChannelIndex[BackLeft] = 4;
+ mDevice->RealOut.ChannelIndex[BackRight] = 5;
+ mDevice->RealOut.ChannelIndex[SideLeft] = 6;
+ mDevice->RealOut.ChannelIndex[SideRight] = 7;
+ break;
+ case DevFmtAmbi3D:
+ mDevice->RealOut.ChannelIndex[Aux0] = 0;
+ if(mDevice->mAmbiOrder > 0)
+ {
+ mDevice->RealOut.ChannelIndex[Aux1] = 1;
+ mDevice->RealOut.ChannelIndex[Aux2] = 2;
+ mDevice->RealOut.ChannelIndex[Aux3] = 3;
+ }
+ if(mDevice->mAmbiOrder > 1)
+ {
+ mDevice->RealOut.ChannelIndex[Aux4] = 4;
+ mDevice->RealOut.ChannelIndex[Aux5] = 5;
+ mDevice->RealOut.ChannelIndex[Aux6] = 6;
+ mDevice->RealOut.ChannelIndex[Aux7] = 7;
+ mDevice->RealOut.ChannelIndex[Aux8] = 8;
+ }
+ if(mDevice->mAmbiOrder > 2)
+ {
+ mDevice->RealOut.ChannelIndex[Aux9] = 9;
+ mDevice->RealOut.ChannelIndex[Aux10] = 10;
+ mDevice->RealOut.ChannelIndex[Aux11] = 11;
+ mDevice->RealOut.ChannelIndex[Aux12] = 12;
+ mDevice->RealOut.ChannelIndex[Aux13] = 13;
+ mDevice->RealOut.ChannelIndex[Aux14] = 14;
+ mDevice->RealOut.ChannelIndex[Aux15] = 15;
+ }
+ break;
+ }
+}
+
+void BackendBase::setDefaultChannelOrder()
+{
+ mDevice->RealOut.ChannelIndex.fill(INVALID_CHANNEL_INDEX);
+
+ switch(mDevice->FmtChans)
+ {
+ case DevFmtX51Rear:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[BackLeft] = 2;
+ mDevice->RealOut.ChannelIndex[BackRight] = 3;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 4;
+ mDevice->RealOut.ChannelIndex[LFE] = 5;
+ return;
+ case DevFmtX71:
+ mDevice->RealOut.ChannelIndex[FrontLeft] = 0;
+ mDevice->RealOut.ChannelIndex[FrontRight] = 1;
+ mDevice->RealOut.ChannelIndex[BackLeft] = 2;
+ mDevice->RealOut.ChannelIndex[BackRight] = 3;
+ mDevice->RealOut.ChannelIndex[FrontCenter] = 4;
+ mDevice->RealOut.ChannelIndex[LFE] = 5;
+ mDevice->RealOut.ChannelIndex[SideLeft] = 6;
+ mDevice->RealOut.ChannelIndex[SideRight] = 7;
+ return;
+
+ /* Same as WFX order */
+ case DevFmtMono:
+ case DevFmtStereo:
+ case DevFmtQuad:
+ case DevFmtX51:
+ case DevFmtX61:
+ case DevFmtAmbi3D:
+ setDefaultWFXChannelOrder();
+ break;
+ }
+}
diff --git a/alc/backends/base.h b/alc/backends/base.h
index 91a494e2..1824649b 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -34,6 +34,12 @@ struct BackendBase {
BackendBase(ALCdevice *device) noexcept : mDevice{device} { }
virtual ~BackendBase() = default;
+
+protected:
+ /** Sets the default channel order used by most non-WaveFormatEx-based APIs. */
+ void setDefaultChannelOrder();
+ /** Sets the default channel order used by WaveFormatEx. */
+ void setDefaultWFXChannelOrder();
};
using BackendPtr = std::unique_ptr<BackendBase>;
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index 12a8cec4..2884bad6 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -195,7 +195,7 @@ bool CoreAudioPlayback::reset()
streamFormat.mChannelsPerFrame = 2;
break;
}
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
/* use channel count and sample rate from the default output unit's current
* parameters, but reset everything else */
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 24fba98c..da857beb 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -558,7 +558,7 @@ retry_open:
}
ResetEvent(mNotifyEvent);
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
return true;
}
@@ -754,7 +754,7 @@ void DSoundCapture::open(const ALCchar *name)
}
mBufferBytes = DSCBDescription.dwBufferBytes;
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
mDevice->DeviceName = name;
}
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 547bf66f..8fe076fb 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -375,7 +375,7 @@ bool JackPlayback::reset()
}
}
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
return true;
}
diff --git a/alc/backends/loopback.cpp b/alc/backends/loopback.cpp
index bee026c8..7f421ea7 100644
--- a/alc/backends/loopback.cpp
+++ b/alc/backends/loopback.cpp
@@ -47,7 +47,7 @@ void LoopbackBackend::open(const ALCchar *name)
bool LoopbackBackend::reset()
{
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
return true;
}
diff --git a/alc/backends/null.cpp b/alc/backends/null.cpp
index 3df75378..6e47f153 100644
--- a/alc/backends/null.cpp
+++ b/alc/backends/null.cpp
@@ -119,7 +119,7 @@ void NullBackend::open(const ALCchar *name)
bool NullBackend::reset()
{
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
return true;
}
diff --git a/alc/backends/oboe.cpp b/alc/backends/oboe.cpp
index d884a0af..4a8188f3 100644
--- a/alc/backends/oboe.cpp
+++ b/alc/backends/oboe.cpp
@@ -169,7 +169,7 @@ bool OboePlayback::reset()
mDevice->FmtChans = DevFmtStereo;
break;
}
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
switch(mStream->getFormat())
{
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index 944437c6..8c235cd2 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -431,7 +431,7 @@ bool OpenSLPlayback::reset()
mDevice->FmtChans = DevFmtStereo;
mDevice->FmtType = DevFmtShort;
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
mFrameSize = mDevice->frameSizeFromFmt();
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index cb3c0adb..70a4a09d 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -425,7 +425,7 @@ bool OSSPlayback::reset()
mDevice->UpdateSize = static_cast<ALuint>(info.fragsize) / frameSize;
mDevice->BufferSize = static_cast<ALuint>(info.fragments) * mDevice->UpdateSize;
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
mMixData.resize(mDevice->UpdateSize * mDevice->frameSizeFromFmt());
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index ac63bcb7..5bb792c3 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -204,7 +204,7 @@ bool PortPlayback::reset()
ERR("Unexpected channel count: %u\n", mParams.channelCount);
return false;
}
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
return true;
}
diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp
index df6e56b1..7666b616 100644
--- a/alc/backends/sdl2.cpp
+++ b/alc/backends/sdl2.cpp
@@ -166,7 +166,7 @@ bool Sdl2Backend::reset()
mDevice->FmtType = mFmtType;
mDevice->UpdateSize = mUpdateSize;
mDevice->BufferSize = mUpdateSize * 2;
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
return true;
}
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index 8af83226..bad05acb 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -242,7 +242,7 @@ bool SndioPlayback::reset()
return false;
}
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
mDevice->UpdateSize = par.round;
mDevice->BufferSize = par.bufsz + par.round;
@@ -440,7 +440,7 @@ void SndioCapture::open(const ALCchar *name)
mRing = RingBuffer::Create(mDevice->BufferSize, par.bps*par.rchan, false);
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
mDevice->DeviceName = name;
}
diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp
index 8309d442..7f6ebb0f 100644
--- a/alc/backends/solaris.cpp
+++ b/alc/backends/solaris.cpp
@@ -220,7 +220,7 @@ bool SolarisBackend::reset()
mDevice->BufferSize = info.play.buffer_size / frameSize;
mDevice->UpdateSize = mDevice->BufferSize / 2;
- SetDefaultChannelOrder(mDevice);
+ setDefaultChannelOrder();
mBuffer.resize(mDevice->UpdateSize * mDevice->frameSizeFromFmt());
std::fill(mBuffer.begin(), mBuffer.end(), 0);
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index 0d2a6dad..89053ed6 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1070,7 +1070,7 @@ HRESULT WasapiPlayback::resetProxy()
mDevice->IsHeadphones = (mDevice->FmtChans == DevFmtStereo
&& (formfactor == Headphones || formfactor == Headset));
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
hr = mClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
buf_time.count(), 0, &OutputType.Format, nullptr);
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp
index a10044de..30a8399b 100644
--- a/alc/backends/wave.cpp
+++ b/alc/backends/wave.cpp
@@ -324,7 +324,7 @@ bool WaveBackend::reset()
}
mDataStart = ftell(mFile);
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
const ALuint bufsize{mDevice->frameSizeFromFmt() * mDevice->UpdateSize};
mBuffer.resize(bufsize);
diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp
index 3bf0a198..e1261969 100644
--- a/alc/backends/winmm.cpp
+++ b/alc/backends/winmm.cpp
@@ -304,7 +304,7 @@ bool WinMMPlayback::reset()
ERR("Unhandled channel count: %d\n", mFormat.nChannels);
return false;
}
- SetDefaultWFXChannelOrder(mDevice);
+ setDefaultWFXChannelOrder();
ALuint BufferSize{mDevice->UpdateSize * mDevice->frameSizeFromFmt()};