obs-studio
obs-studio copied to clipboard
UI: Fix low value of std::clamp gets greater than high value
Description
This commit partially reverts 60a45d3aa3 to avoid a runtime assertion failure on Windows that checks the low value of std::clamp is not greater than the high value.
To clarify the necessity to consider the priority, I didn't revert to use the CLAMP
macro but use an if-else-if statement.
Motivation and Context
I modified to use std::clamp
in the PR #11167.
However, @exeldro reported it caused a runtime error on Windows.
I confirmed the low value (currentPeak[channelNr]
) gets greater than the high value (0.f
) by applying a gain filter with a large gain.
How Has This Been Tested?
OS Fedora 39
Applied a gain filter with a large gain.
Checked the other std::clamp
usage, I checked minimumLevel
never gets larger than 0 by eyeball.
https://github.com/obsproject/obs-studio/blob/8251005ad3acb54a67b68e2cb0846a783f0aeed7/UI/volume-control.cpp#L1062-L1064
Types of changes
- Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] My code has been run through clang-format.
- [x] I have read the contributing document.
- [ ] My code is not on the master branch.
- [x] The code has been tested.
- [x] All commit messages are properly formatted and commits squashed where appropriate.
- [x] I have included updates to all appropriate documentation.