Reorganize how some device fields are set and reset
This commit is contained in:
parent
8670fca3dc
commit
0a532729ba
53
Alc/alc.cpp
53
Alc/alc.cpp
@ -1810,14 +1810,21 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
if(device->Flags.get<DeviceRunning>())
|
||||
return ALC_NO_ERROR;
|
||||
|
||||
device->AvgSpeakerDist = 0.0f;
|
||||
device->Uhj_Encoder = nullptr;
|
||||
device->AmbiDecoder = nullptr;
|
||||
device->Bs2b = nullptr;
|
||||
device->PostProcess = nullptr;
|
||||
|
||||
device->Stablizer = nullptr;
|
||||
device->Limiter = nullptr;
|
||||
device->ChannelDelay.clear();
|
||||
|
||||
device->Dry.AmbiMap.fill(BFChannelConfig{});
|
||||
device->Dry.Buffer = nullptr;
|
||||
device->Dry.NumChannels = 0;
|
||||
std::fill(std::begin(device->NumChannelsPerOrder), std::end(device->NumChannelsPerOrder), 0u);
|
||||
device->RealOut.ChannelIndex.fill(-1);
|
||||
device->RealOut.Buffer = nullptr;
|
||||
device->RealOut.NumChannels = 0;
|
||||
device->MixBuffer.clear();
|
||||
@ -1826,6 +1833,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
UpdateClockBase(device);
|
||||
device->FixedLatency = nanoseconds::zero();
|
||||
|
||||
device->DitherDepth = 0.0f;
|
||||
device->DitherSeed = DITHER_RNG_SEED;
|
||||
|
||||
/*************************************************************************
|
||||
@ -1947,10 +1955,47 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
|
||||
device->NumAuxSends = new_sends;
|
||||
TRACE("Max sources: %d (%d + %d), effect slots: %d, sends: %d\n",
|
||||
device->SourcesMax, device->NumMonoSources, device->NumStereoSources,
|
||||
device->AuxiliaryEffectSlotMax, device->NumAuxSends);
|
||||
device->SourcesMax, device->NumMonoSources, device->NumStereoSources,
|
||||
device->AuxiliaryEffectSlotMax, device->NumAuxSends);
|
||||
|
||||
/* Enable the stablizer only for formats that have front-left, front-right,
|
||||
* and front-center outputs.
|
||||
*/
|
||||
switch(device->FmtChans)
|
||||
{
|
||||
case DevFmtX51:
|
||||
case DevFmtX51Rear:
|
||||
case DevFmtX61:
|
||||
case DevFmtX71:
|
||||
if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "front-stablizer", 0))
|
||||
{
|
||||
auto stablizer = al::make_unique<FrontStablizer>();
|
||||
/* Initialize band-splitting filters for the front-left and
|
||||
* front-right channels, with a crossover at 5khz (could be
|
||||
* higher).
|
||||
*/
|
||||
const ALfloat scale{static_cast<ALfloat>(5000.0 / device->Frequency)};
|
||||
|
||||
stablizer->LFilter.init(scale);
|
||||
stablizer->RFilter = stablizer->LFilter;
|
||||
|
||||
device->Stablizer = std::move(stablizer);
|
||||
/* NOTE: Don't know why this has to be "copied" into a local static
|
||||
* constexpr variable to avoid a reference on
|
||||
* FrontStablizer::DelayLength...
|
||||
*/
|
||||
static constexpr size_t StablizerDelay{FrontStablizer::DelayLength};
|
||||
device->FixedLatency += nanoseconds{seconds{StablizerDelay}} / device->Frequency;
|
||||
}
|
||||
break;
|
||||
case DevFmtMono:
|
||||
case DevFmtStereo:
|
||||
case DevFmtQuad:
|
||||
case DevFmtAmbi3D:
|
||||
break;
|
||||
}
|
||||
TRACE("Front stablizer %s\n", device->Stablizer ? "enabled" : "disabled");
|
||||
|
||||
device->DitherDepth = 0.0f;
|
||||
if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "dither", 1))
|
||||
{
|
||||
ALint depth = 0;
|
||||
@ -2043,8 +2088,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
TRACE("Output limiter enabled, %.4fdB limit\n", thrshld_dB);
|
||||
}
|
||||
|
||||
aluSelectPostProcess(device);
|
||||
|
||||
TRACE("Fixed device latency: %ldns\n", (long)device->FixedLatency.count());
|
||||
|
||||
/* Need to delay returning failure until replacement Send arrays have been
|
||||
|
29
Alc/alu.cpp
29
Alc/alu.cpp
@ -124,6 +124,13 @@ inline HrtfDirectMixerFunc SelectHrtfMixer(void)
|
||||
return MixDirectHrtf_<CTag>;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void aluInit(void)
|
||||
{
|
||||
MixDirectHrtf = SelectHrtfMixer();
|
||||
}
|
||||
|
||||
|
||||
void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
|
||||
{
|
||||
@ -174,28 +181,6 @@ void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo)
|
||||
device->RealOut.Buffer[ridx].data(), SamplesToDo);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void aluInit(void)
|
||||
{
|
||||
MixDirectHrtf = SelectHrtfMixer();
|
||||
}
|
||||
|
||||
|
||||
void aluSelectPostProcess(ALCdevice *device)
|
||||
{
|
||||
if(device->mHrtf)
|
||||
device->PostProcess = ProcessHrtf;
|
||||
else if(device->AmbiDecoder)
|
||||
device->PostProcess = ProcessAmbiDec;
|
||||
else if(device->Uhj_Encoder)
|
||||
device->PostProcess = ProcessUhj;
|
||||
else if(device->Bs2b)
|
||||
device->PostProcess = ProcessBs2b;
|
||||
else
|
||||
device->PostProcess = nullptr;
|
||||
}
|
||||
|
||||
|
||||
/* Prepares the interpolator for a given rate (determined by increment).
|
||||
*
|
||||
|
@ -754,16 +754,6 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
||||
device->HrtfName.clear();
|
||||
device->mRenderMode = NormalRender;
|
||||
|
||||
device->Dry.AmbiMap.fill(BFChannelConfig{});
|
||||
device->Dry.NumChannels = 0;
|
||||
std::fill(std::begin(device->NumChannelsPerOrder), std::end(device->NumChannelsPerOrder), 0u);
|
||||
|
||||
device->AvgSpeakerDist = 0.0f;
|
||||
device->ChannelDelay.clear();
|
||||
|
||||
device->AmbiDecoder = nullptr;
|
||||
device->Stablizer = nullptr;
|
||||
|
||||
if(device->FmtChans != DevFmtStereo)
|
||||
{
|
||||
if(old_hrtf)
|
||||
@ -816,50 +806,11 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
||||
int hqdec{GetConfigValueBool(devname, "decoder", "hq-mode", 0)};
|
||||
InitCustomPanning(device, !!hqdec, pconf, speakermap);
|
||||
}
|
||||
|
||||
/* Enable the stablizer only for formats that have front-left, front-
|
||||
* right, and front-center outputs.
|
||||
*/
|
||||
switch(device->FmtChans)
|
||||
{
|
||||
case DevFmtX51:
|
||||
case DevFmtX51Rear:
|
||||
case DevFmtX61:
|
||||
case DevFmtX71:
|
||||
if(GetConfigValueBool(devname, nullptr, "front-stablizer", 0))
|
||||
{
|
||||
auto stablizer = al::make_unique<FrontStablizer>();
|
||||
/* Initialize band-splitting filters for the front-left and
|
||||
* front-right channels, with a crossover at 5khz (could be
|
||||
* higher).
|
||||
*/
|
||||
const ALfloat scale{static_cast<ALfloat>(5000.0 / device->Frequency)};
|
||||
|
||||
stablizer->LFilter.init(scale);
|
||||
stablizer->RFilter = stablizer->LFilter;
|
||||
|
||||
device->Stablizer = std::move(stablizer);
|
||||
/* NOTE: Don't know why this has to be "copied" into a local
|
||||
* static constexpr variable to avoid a reference on
|
||||
* FrontStablizer::DelayLength...
|
||||
*/
|
||||
static constexpr size_t StablizerDelay{FrontStablizer::DelayLength};
|
||||
device->FixedLatency += nanoseconds{seconds{StablizerDelay}} / device->Frequency;
|
||||
}
|
||||
break;
|
||||
case DevFmtMono:
|
||||
case DevFmtStereo:
|
||||
case DevFmtQuad:
|
||||
case DevFmtAmbi3D:
|
||||
break;
|
||||
}
|
||||
TRACE("Front stablizer %s\n", device->Stablizer ? "enabled" : "disabled");
|
||||
|
||||
if(device->AmbiDecoder)
|
||||
device->PostProcess = ProcessAmbiDec;
|
||||
return;
|
||||
}
|
||||
|
||||
device->AmbiDecoder = nullptr;
|
||||
|
||||
bool headphones{device->IsHeadphones != AL_FALSE};
|
||||
if(device->Type != Loopback)
|
||||
{
|
||||
@ -937,6 +888,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
||||
old_hrtf = nullptr;
|
||||
|
||||
InitHrtfPanning(device);
|
||||
device->PostProcess = ProcessHrtf;
|
||||
return;
|
||||
}
|
||||
device->HrtfStatus = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT;
|
||||
@ -958,6 +910,7 @@ no_hrtf:
|
||||
bs2b_set_params(device->Bs2b.get(), bs2blevel, device->Frequency);
|
||||
TRACE("BS2B enabled\n");
|
||||
InitPanning(device);
|
||||
device->PostProcess = ProcessBs2b;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -974,11 +927,13 @@ no_hrtf:
|
||||
device->Uhj_Encoder = al::make_unique<Uhj2Encoder>();
|
||||
TRACE("UHJ enabled\n");
|
||||
InitUhjPanning(device);
|
||||
device->PostProcess = ProcessUhj;
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE("Stereo rendering\n");
|
||||
InitPanning(device);
|
||||
device->PostProcess = ProcessAmbiDec;
|
||||
}
|
||||
|
||||
|
||||
|
@ -388,7 +388,10 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
|
||||
|
||||
void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device);
|
||||
|
||||
void aluSelectPostProcess(ALCdevice *device);
|
||||
void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo);
|
||||
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo);
|
||||
void ProcessUhj(ALCdevice *device, const ALsizei SamplesToDo);
|
||||
void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo);
|
||||
|
||||
/**
|
||||
* Calculates ambisonic encoder coefficients using the X, Y, and Z direction
|
||||
|
Loading…
x
Reference in New Issue
Block a user