From 571eee359ff9d6ee574ee4aeae296a5b2abd8a18 Mon Sep 17 00:00:00 2001 From: vittorioromeo Date: Mon, 10 Jun 2024 23:02:16 +0200 Subject: [PATCH] Fix speaker name conflicts with miniaudio macros in unity builds --- src/SFML/Audio/SoundFileWriterWav.cpp | 74 +++++++++++++-------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index b14bb2c24..ee3c220c0 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -108,27 +108,25 @@ bool SoundFileWriterWav::open(const std::filesystem::path& filename, } else { - // NOLINTBEGIN(readability-identifier-naming) // For WAVE channel mapping refer to: https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653308(v=vs.85)#default-channel-ordering - static constexpr auto SPEAKER_FRONT_LEFT = 0x1u; - static constexpr auto SPEAKER_FRONT_RIGHT = 0x2u; - static constexpr auto SPEAKER_FRONT_CENTER = 0x4u; - static constexpr auto SPEAKER_LOW_FREQUENCY = 0x8u; - static constexpr auto SPEAKER_BACK_LEFT = 0x10u; - static constexpr auto SPEAKER_BACK_RIGHT = 0x20u; - static constexpr auto SPEAKER_FRONT_LEFT_OF_CENTER = 0x40u; - static constexpr auto SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80u; - static constexpr auto SPEAKER_BACK_CENTER = 0x100u; - static constexpr auto SPEAKER_SIDE_LEFT = 0x200u; - static constexpr auto SPEAKER_SIDE_RIGHT = 0x400u; - static constexpr auto SPEAKER_TOP_CENTER = 0x800u; - static constexpr auto SPEAKER_TOP_FRONT_LEFT = 0x1000u; - static constexpr auto SPEAKER_TOP_FRONT_CENTER = 0x2000u; - static constexpr auto SPEAKER_TOP_FRONT_RIGHT = 0x4000u; - static constexpr auto SPEAKER_TOP_BACK_LEFT = 0x8000u; - static constexpr auto SPEAKER_TOP_BACK_CENTER = 0x10000u; - static constexpr auto SPEAKER_TOP_BACK_RIGHT = 0x20000u; - // NOLINTEND(readability-identifier-naming) + static constexpr auto speakerFrontLeft = 0x1u; + static constexpr auto speakerFrontRight = 0x2u; + static constexpr auto speakerFrontCenter = 0x4u; + static constexpr auto speakerLowFrequency = 0x8u; + static constexpr auto speakerBackLeft = 0x10u; + static constexpr auto speakerBackRight = 0x20u; + static constexpr auto speakerFrontLeftOfCenter = 0x40u; + static constexpr auto speakerFrontRightOfCenter = 0x80u; + static constexpr auto speakerBackCenter = 0x100u; + static constexpr auto speakerSideLeft = 0x200u; + static constexpr auto speakerSideRight = 0x400u; + static constexpr auto speakerTopCenter = 0x800u; + static constexpr auto speakerTopFrontLeft = 0x1000u; + static constexpr auto speakerTopFrontCenter = 0x2000u; + static constexpr auto speakerTopFrontRight = 0x4000u; + static constexpr auto speakerTopBackLeft = 0x8000u; + static constexpr auto speakerTopBackCenter = 0x10000u; + static constexpr auto speakerTopBackRight = 0x20000u; struct SupportedChannel { @@ -137,24 +135,24 @@ bool SoundFileWriterWav::open(const std::filesystem::path& filename, }; std::vector - targetChannelMap{{SPEAKER_FRONT_LEFT, SoundChannel::FrontLeft}, - {SPEAKER_FRONT_RIGHT, SoundChannel::FrontRight}, - {SPEAKER_FRONT_CENTER, SoundChannel::FrontCenter}, - {SPEAKER_LOW_FREQUENCY, SoundChannel::LowFrequencyEffects}, - {SPEAKER_BACK_LEFT, SoundChannel::BackLeft}, - {SPEAKER_BACK_RIGHT, SoundChannel::BackRight}, - {SPEAKER_FRONT_LEFT_OF_CENTER, SoundChannel::FrontLeftOfCenter}, - {SPEAKER_FRONT_RIGHT_OF_CENTER, SoundChannel::FrontRightOfCenter}, - {SPEAKER_BACK_CENTER, SoundChannel::BackCenter}, - {SPEAKER_SIDE_LEFT, SoundChannel::SideLeft}, - {SPEAKER_SIDE_RIGHT, SoundChannel::SideRight}, - {SPEAKER_TOP_CENTER, SoundChannel::TopCenter}, - {SPEAKER_TOP_FRONT_LEFT, SoundChannel::TopFrontLeft}, - {SPEAKER_TOP_FRONT_CENTER, SoundChannel::TopFrontCenter}, - {SPEAKER_TOP_FRONT_RIGHT, SoundChannel::TopFrontRight}, - {SPEAKER_TOP_BACK_LEFT, SoundChannel::TopBackLeft}, - {SPEAKER_TOP_BACK_CENTER, SoundChannel::TopBackCenter}, - {SPEAKER_TOP_BACK_RIGHT, SoundChannel::TopBackRight}}; + targetChannelMap{{speakerFrontLeft, SoundChannel::FrontLeft}, + {speakerFrontRight, SoundChannel::FrontRight}, + {speakerFrontCenter, SoundChannel::FrontCenter}, + {speakerLowFrequency, SoundChannel::LowFrequencyEffects}, + {speakerBackLeft, SoundChannel::BackLeft}, + {speakerBackRight, SoundChannel::BackRight}, + {speakerFrontLeftOfCenter, SoundChannel::FrontLeftOfCenter}, + {speakerFrontRightOfCenter, SoundChannel::FrontRightOfCenter}, + {speakerBackCenter, SoundChannel::BackCenter}, + {speakerSideLeft, SoundChannel::SideLeft}, + {speakerSideRight, SoundChannel::SideRight}, + {speakerTopCenter, SoundChannel::TopCenter}, + {speakerTopFrontLeft, SoundChannel::TopFrontLeft}, + {speakerTopFrontCenter, SoundChannel::TopFrontCenter}, + {speakerTopFrontRight, SoundChannel::TopFrontRight}, + {speakerTopBackLeft, SoundChannel::TopBackLeft}, + {speakerTopBackCenter, SoundChannel::TopBackCenter}, + {speakerTopBackRight, SoundChannel::TopBackRight}}; // Check for duplicate channel entries {