diff options
author | Chris Robinson <[email protected]> | 2023-01-08 01:36:11 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-08 01:36:11 -0800 |
commit | 716f5373cbe7e2c761ab1bb7b5a432ce178ed407 (patch) | |
tree | 7b06ca217963605c261444990069288b0c9c8e8b /alc | |
parent | 0ed70ec4afd35277a208229aa8009d9fdf68fd3d (diff) |
Better handle negative sample rate values
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 40ca9a44..cf510ab4 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1795,7 +1795,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) { ALenum outmode{ALC_ANY_SOFT}; al::optional<bool> opthrtf; - uint freqAttr{}; + int freqAttr{}; #define ATTRIBUTE(a) a: TRACE("%s = %d\n", #a, attrList[attrIdx + 1]); size_t attrIdx{0}; @@ -1814,7 +1814,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) break; case ATTRIBUTE(ALC_FREQUENCY) - freqAttr = static_cast<uint>(attrList[attrIdx + 1]); + freqAttr = attrList[attrIdx + 1]; break; case ATTRIBUTE(ALC_AMBISONIC_LAYOUT_SOFT) @@ -1913,7 +1913,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) stereomode = StereoEncoding::Hrtf; } - optsrate = freqAttr; + optsrate = static_cast<uint>(freqAttr); } else { @@ -1947,12 +1947,12 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) if(freqAttr) { uint oldrate = optsrate.value_or(DEFAULT_OUTPUT_RATE); - freqAttr = clampu(freqAttr, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE); + freqAttr = clampi(freqAttr, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE); const double scale{static_cast<double>(freqAttr) / oldrate}; period_size = static_cast<uint>(period_size*scale + 0.5); buffer_size = static_cast<uint>(buffer_size*scale + 0.5); - optsrate = freqAttr; + optsrate = static_cast<uint>(freqAttr); } } |