Pass a parameter to aluInitRenderer to specify UHJ output
This commit is contained in:
parent
837652624b
commit
096bed35fa
14
alc/alc.cpp
14
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",
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user