mkxp-z/subprojects/packagefiles/openal-soft-int32.patch
刘皓 74f4c0e714
Downgrade OpenAL Soft from 1.24.2 to 1.23.1 in libretro builds
OpenAL Soft 1.24 introduces a lot of code that doesn't work well with
the PlayStation 3 homebrew toolchain, and also the old version of the
Wii U homebrew toolchain currently used by the libretro buildbot.
Instead of maintaining a bunch of patches to get 1.24 to work on these
toolchains, I think it'd be easier to just use 1.23.
2025-04-08 14:27:20 -04:00

69 lines
3.9 KiB
Diff

# Fixes compilation errors when using the devkitARM toolchain to compile OpenAL Soft.
# For some reason, there's no implicit casting between `int` and `int32_t` and between `unsigned int` and `uint32_t` in devkitARM even though they're the same size, so we have to do this whole song and dance to appease the compiler.
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -2008,7 +2008,7 @@ inline T SampleConv(float) noexcept;
template<> inline float SampleConv(float val) noexcept
{ return val; }
-template<> inline int32_t SampleConv(float val) noexcept
+template<> inline int SampleConv(float val) noexcept
{
/* Floats have a 23-bit mantissa, plus an implied 1 bit and a sign bit.
* This means a normalized float has at most 25 bits of signed precision.
@@ -2017,13 +2017,16 @@ template<> inline int32_t SampleConv(float val) noexcept
*/
return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f));
}
+#ifdef __DEVKITARM__
+template<> inline long SampleConv(float val) noexcept { return (long)SampleConv<int>(val); }
+#endif
template<> inline int16_t SampleConv(float val) noexcept
{ return static_cast<int16_t>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
template<> inline int8_t SampleConv(float val) noexcept
{ return static_cast<int8_t>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
/* Define unsigned output variations. */
-template<> inline uint32_t SampleConv(float val) noexcept
+template<> inline unsigned int SampleConv(float val) noexcept
{ return static_cast<uint32_t>(SampleConv<int32_t>(val)) + 2147483648u; }
template<> inline uint16_t SampleConv(float val) noexcept
{ return static_cast<uint16_t>(SampleConv<int16_t>(val) + 32768); }
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -80,16 +80,16 @@ inline DevFmtType_t<T> StoreSample(float) noexcept;
template<> inline float StoreSample<DevFmtFloat>(float val) noexcept
{ return val; }
-template<> inline int32_t StoreSample<DevFmtInt>(float val) noexcept
-{ return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); }
+template<> inline int StoreSample<DevFmtInt>(float val) noexcept
+{ static_assert(sizeof(int) == sizeof(int32_t), "`int` should be a 32-bit integer"); return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); }
template<> inline int16_t StoreSample<DevFmtShort>(float val) noexcept
{ return static_cast<int16_t>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
template<> inline int8_t StoreSample<DevFmtByte>(float val) noexcept
{ return static_cast<int8_t>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
/* Define unsigned output variations. */
-template<> inline uint32_t StoreSample<DevFmtUInt>(float val) noexcept
-{ return static_cast<uint32_t>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
+template<> inline unsigned int StoreSample<DevFmtUInt>(float val) noexcept
+{ static_assert(sizeof(unsigned int) == sizeof(uint32_t), "`unsigned int` should be a 32-bit integer"); return static_cast<uint32_t>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
template<> inline uint16_t StoreSample<DevFmtUShort>(float val) noexcept
{ return static_cast<uint16_t>(StoreSample<DevFmtShort>(val) + 32768); }
template<> inline uint8_t StoreSample<DevFmtUByte>(float val) noexcept
--- a/core/devformat.h
+++ b/core/devformat.h
@@ -86,9 +86,9 @@ struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
template<>
struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
template<>
-struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
+struct DevFmtTypeTraits<DevFmtInt> { static_assert(sizeof(int) == sizeof(int32_t), "`int` should be a 32-bit integer"); using Type = int; };
template<>
-struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
+struct DevFmtTypeTraits<DevFmtUInt> { static_assert(sizeof(unsigned int) == sizeof(uint32_t), "`unsigned int` should be a 32-bit integer"); using Type = unsigned int; };
template<>
struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };