|
1 | | -# Fixes a compilation error when using the devkitARM toolchain or Vita SDK toolchain to compile OpenAL Soft. |
| 1 | +# Fixes compilation errors when using the devkitARM toolchain toolchain to compile OpenAL Soft. |
2 | 2 | # For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM or Vita SDK even though they're the same size, so we have to do this whole song and dance to appease the compiler. |
3 | 3 |
|
| 4 | +--- a/alc/alu.cpp |
| 5 | ++++ b/alc/alu.cpp |
| 6 | +@@ -2114,7 +2114,7 @@ inline T SampleConv(float) noexcept; |
| 7 | + |
| 8 | + template<> inline float SampleConv(float val) noexcept |
| 9 | + { return val; } |
| 10 | +-template<> inline int32_t SampleConv(float val) noexcept |
| 11 | ++template<> inline int SampleConv(float val) noexcept |
| 12 | + { |
| 13 | + /* Floats have a 23-bit mantissa, plus an implied 1 bit and a sign bit. |
| 14 | + * This means a normalized float has at most 25 bits of signed precision. |
| 15 | +@@ -2123,13 +2123,16 @@ template<> inline int32_t SampleConv(float val) noexcept |
| 16 | + */ |
| 17 | + return fastf2i(std::clamp(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); |
| 18 | + } |
| 19 | ++#ifdef __DEVKITARM__ |
| 20 | ++template<> inline long SampleConv(float val) noexcept { return (long)SampleConv<int>(val); } |
| 21 | ++#endif |
| 22 | + template<> inline int16_t SampleConv(float val) noexcept |
| 23 | + { return static_cast<int16_t>(fastf2i(std::clamp(val*32768.0f, -32768.0f, 32767.0f))); } |
| 24 | + template<> inline int8_t SampleConv(float val) noexcept |
| 25 | + { return static_cast<int8_t>(fastf2i(std::clamp(val*128.0f, -128.0f, 127.0f))); } |
| 26 | + |
| 27 | + /* Define unsigned output variations. */ |
| 28 | +-template<> inline uint32_t SampleConv(float val) noexcept |
| 29 | ++template<> inline unsigned int SampleConv(float val) noexcept |
| 30 | + { return static_cast<uint32_t>(SampleConv<int32_t>(val)) + 2147483648u; } |
| 31 | + template<> inline uint16_t SampleConv(float val) noexcept |
| 32 | + { return static_cast<uint16_t>(SampleConv<int16_t>(val) + 32768); } |
4 | 33 | --- a/core/converter.cpp |
5 | 34 | +++ b/core/converter.cpp |
6 | 35 | @@ -83,16 +83,16 @@ inline DevFmtType_t<T> StoreSample(float) noexcept; |
|
0 commit comments