aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alc/alc.cpp14
-rw-r--r--alc/alu.h2
-rw-r--r--alc/panning.cpp34
3 files changed, 27 insertions, 23 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 44cc0f93..8f065bd2 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -1523,6 +1523,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
ALCenum gainLimiter{device->LimiterState};
uint new_sends{device->NumAuxSends};
al::optional<bool> hrtfreq{};
+ al::optional<bool> uhjreq{};
DevFmtChannels oldChans;
DevFmtType oldType;
int hrtf_id{-1};
@@ -1847,9 +1848,20 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
else if(al::strcasecmp(mode, "auto") != 0)
ERR("Unexpected stereo-mode: %s\n", mode);
}
+
+ if(auto encopt = device->configValue<std::string>(nullptr, "stereo-encoding"))
+ {
+ const char *mode{encopt->c_str()};
+ if(al::strcasecmp(mode, "uhj") == 0)
+ uhjreq = al::make_optional(true);
+ else if(al::strcasecmp(mode, "panpot") == 0)
+ uhjreq = al::make_optional(false);
+ else
+ ERR("Unexpected stereo-encoding: %s\n", mode);
+ }
}
- aluInitRenderer(device, hrtf_id, hrtfreq);
+ aluInitRenderer(device, hrtf_id, hrtfreq, uhjreq.value_or(false));
device->NumAuxSends = new_sends;
TRACE("Max sources: %d (%d + %d), effect slots: %d, sends: %d\n",
diff --git a/alc/alu.h b/alc/alu.h
index 05d3b92c..addf6942 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -20,7 +20,7 @@ void aluInit(void);
* Set up the appropriate panning method and mixing method given the device
* properties.
*/
-void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq);
+void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq, bool useuhj);
void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context);
diff --git a/alc/panning.cpp b/alc/panning.cpp
index 7b2215a4..151e86e8 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -822,7 +822,7 @@ void InitUhjPanning(ALCdevice *device)
} // namespace
-void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq)
+void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq, bool useuhj)
{
/* Hold the HRTF the device last used, in case it's used again. */
HrtfStorePtr old_hrtf{std::move(device->mHrtf)};
@@ -922,10 +922,10 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq)
}
- /* If there's no request for HRTF and the device is headphones, or if HRTF
- * is explicitly requested, try to enable it.
+ /* If there's no request for HRTF or UHJ and the device is headphones, or
+ * if HRTF is explicitly requested, try to enable it.
*/
- if((!hrtfreq && device->Flags.test(DirectEar)) || hrtfreq.value_or(false))
+ if((!hrtfreq && !useuhj && device->Flags.test(DirectEar)) || hrtfreq.value_or(false))
{
if(device->mHrtfList.empty())
device->enumerateHrtfs();
@@ -973,6 +973,15 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq)
}
old_hrtf = nullptr;
+ if(useuhj)
+ {
+ device->mUhjEncoder = std::make_unique<UhjEncoder>();
+ TRACE("UHJ enabled\n");
+ InitUhjPanning(device);
+ device->PostProcess = &ALCdevice::ProcessUhj;
+ return;
+ }
+
device->mRenderMode = RenderMode::Pairwise;
if(device->Type != DeviceType::Loopback)
{
@@ -991,23 +1000,6 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<bool> hrtfreq)
}
}
- if(auto encopt = device->configValue<std::string>(nullptr, "stereo-encoding"))
- {
- const char *mode{encopt->c_str()};
- if(al::strcasecmp(mode, "uhj") == 0)
- device->mRenderMode = RenderMode::Normal;
- else if(al::strcasecmp(mode, "panpot") != 0)
- ERR("Unexpected stereo-encoding: %s\n", mode);
- }
- if(device->mRenderMode == RenderMode::Normal)
- {
- device->mUhjEncoder = std::make_unique<UhjEncoder>();
- TRACE("UHJ enabled\n");
- InitUhjPanning(device);
- device->PostProcess = &ALCdevice::ProcessUhj;
- return;
- }
-
TRACE("Stereo rendering\n");
InitPanning(device);
device->PostProcess = &ALCdevice::ProcessAmbiDec;