diff options
author | Chris Robinson <[email protected]> | 2020-09-12 01:52:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-12 01:52:45 -0700 |
commit | bb90bfd9b3a93c93b341ee6c73f18b1dc611714e (patch) | |
tree | a7a4c7e7ad0d7e1dcaa9efa88f61296c8ce6093d /alc | |
parent | cf298075b54f6b3af9a563097d9d07b9d6aac4a8 (diff) |
Accumulate delays as samples before calculating nanoseconds
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index e4db2681..c72bc320 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1985,23 +1985,15 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) device->SourcesMax, device->NumMonoSources, device->NumStereoSources, device->AuxiliaryEffectSlotMax, device->NumAuxSends); + nanoseconds::rep sample_delay{0}; if(device->Uhj_Encoder) - { - /* NOTE: Don't know why this has to be "copied" into a local constexpr - * variable to avoid a reference on Uhj2Encoder::sFilterSize... - */ - constexpr size_t filter_len{Uhj2Encoder::sFilterSize}; - device->FixedLatency += nanoseconds{seconds{filter_len}} / device->Frequency; - } + sample_delay += Uhj2Encoder::sFilterSize; if(device->mHrtfState) - device->FixedLatency += nanoseconds{seconds{HRTF_DIRECT_DELAY}} / device->Frequency; + sample_delay += HRTF_DIRECT_DELAY; if(auto *ambidec = device->AmbiDecoder.get()) { if(ambidec->hasStablizer()) - { - constexpr size_t StablizerDelay{FrontStablizer::DelayLength}; - device->FixedLatency += nanoseconds{seconds{StablizerDelay}} / device->Frequency; - } + sample_delay += FrontStablizer::DelayLength; } if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "dither", 1)) @@ -2089,12 +2081,14 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) const float thrshld_dB{std::log10(thrshld) * 20.0f}; auto limiter = CreateDeviceLimiter(device, thrshld_dB); - /* Convert the lookahead from samples to nanosamples to nanoseconds. */ - device->FixedLatency += nanoseconds{seconds{limiter->getLookAhead()}} / device->Frequency; + + sample_delay += limiter->getLookAhead(); device->Limiter = std::move(limiter); TRACE("Output limiter enabled, %.4fdB limit\n", thrshld_dB); } + /* Convert the sample delay from samples to nanosamples to nanoseconds. */ + device->FixedLatency += nanoseconds{seconds{sample_delay}} / device->Frequency; TRACE("Fixed device latency: %" PRId64 "ns\n", int64_t{device->FixedLatency.count()}); FPUCtl mixer_mode{}; |