diff options
author | Chris Robinson <[email protected]> | 2023-12-25 05:21:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-25 05:21:42 -0800 |
commit | ec914e895ff6d7bf2d19e8c8785e5d8bfd38629f (patch) | |
tree | 80a5efc31bbc88d76bce3e7116d27dcf14390870 /alc/backends/pipewire.cpp | |
parent | dae225e88dbf795e776a2c9f2dbe5bb07c2228b9 (diff) |
Use standard methods for rounding
Diffstat (limited to 'alc/backends/pipewire.cpp')
-rw-r--r-- | alc/backends/pipewire.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 2e6e20cc..c31f943e 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -1629,11 +1629,12 @@ bool PipeWirePlayback::reset() { /* Scale the update size if the sample rate changes. */ const double scale{static_cast<double>(match->mSampleRate) / mDevice->Frequency}; - const double numbufs{static_cast<double>(mDevice->BufferSize)/mDevice->UpdateSize}; + const double updatesize{std::round(mDevice->UpdateSize * scale)}; + const double buffersize{std::round(mDevice->BufferSize * scale)}; + mDevice->Frequency = match->mSampleRate; - mDevice->UpdateSize = static_cast<uint>(clampd(mDevice->UpdateSize*scale + 0.5, - 64.0, 8192.0)); - mDevice->BufferSize = static_cast<uint>(numbufs*mDevice->UpdateSize + 0.5); + mDevice->UpdateSize = static_cast<uint>(clampd(updatesize, 64.0, 8192.0)); + mDevice->BufferSize = static_cast<uint>(maxd(buffersize, 128.0)); } if(!mDevice->Flags.test(ChannelsRequest) && match->mChannels != InvalidChannelConfig) mDevice->FmtChans = match->mChannels; |