diff options
author | Chris Robinson <[email protected]> | 2019-03-26 10:18:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-26 10:20:32 -0700 |
commit | 525b5e65b2cbe519c561b9995c84ef3e885aa5ab (patch) | |
tree | f5b4d5c2f6922771d24836143eb3327b0be04cf7 | |
parent | 2c37d4fae1effb6791912bd1cff64777291bec78 (diff) |
Remove a couple unnecessary duration_casts
-rw-r--r-- | Alc/alc.cpp | 17 | ||||
-rw-r--r-- | Alc/backends/base.h | 3 |
2 files changed, 9 insertions, 11 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index df001a72..5904dc71 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -1569,11 +1569,9 @@ static inline void UpdateClockBase(ALCdevice *device) { using std::chrono::seconds; using std::chrono::nanoseconds; - using std::chrono::duration_cast; IncrementRef(&device->MixCount); - device->ClockBase += duration_cast<nanoseconds>(seconds{device->SamplesDone}) / - device->Frequency; + device->ClockBase += nanoseconds{seconds{device->SamplesDone}} / device->Frequency; device->SamplesDone = 0; IncrementRef(&device->MixCount); } @@ -1585,6 +1583,9 @@ static inline void UpdateClockBase(ALCdevice *device) */ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { + using std::chrono::seconds; + using std::chrono::nanoseconds; + HrtfRequestMode hrtf_userreq = Hrtf_Default; HrtfRequestMode hrtf_appreq = Hrtf_Default; ALCenum gainLimiter = device->LimiterState; @@ -1829,7 +1830,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->MixBuffer.shrink_to_fit(); UpdateClockBase(device); - device->FixedLatency = std::chrono::nanoseconds::zero(); + device->FixedLatency = nanoseconds::zero(); device->DitherSeed = DITHER_RNG_SEED; @@ -2036,8 +2037,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) auto limiter = CreateDeviceLimiter(device, std::log10(thrshld) * 20.0f); /* Convert the lookahead from samples to nanosamples to nanoseconds. */ - device->FixedLatency += std::chrono::duration_cast<std::chrono::nanoseconds>( - std::chrono::seconds(limiter->getLookAhead())) / device->Frequency; + device->FixedLatency += nanoseconds{seconds{limiter->getLookAhead()}} / device->Frequency; device->Limiter = std::move(limiter); } TRACE("Output limiter %s\n", device->Limiter ? "enabled" : "disabled"); @@ -3265,7 +3265,6 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, { std::lock_guard<std::mutex> _{dev->StateLock}; using std::chrono::seconds; using std::chrono::nanoseconds; - using std::chrono::duration_cast; nanoseconds basecount; ALuint samplecount; @@ -3276,8 +3275,8 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, basecount = dev->ClockBase; samplecount = dev->SamplesDone; } while(refcount != ReadRef(&dev->MixCount)); - *values = (duration_cast<nanoseconds>(seconds{samplecount})/dev->Frequency + - basecount).count(); + basecount += nanoseconds{seconds{samplecount}} / dev->Frequency; + *values = basecount.count(); } break; diff --git a/Alc/backends/base.h b/Alc/backends/base.h index b086104d..2498bcd2 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -21,9 +21,8 @@ inline std::chrono::nanoseconds GetDeviceClockTime(ALCdevice *device) { using std::chrono::seconds; using std::chrono::nanoseconds; - using std::chrono::duration_cast; - auto ns = duration_cast<nanoseconds>(seconds{device->SamplesDone}) / device->Frequency; + auto ns = nanoseconds{seconds{device->SamplesDone}} / device->Frequency; return device->ClockBase + ns; } |