diff --git a/scene/resources/audio_stream_polyphonic.cpp b/scene/resources/audio_stream_polyphonic.cpp index 45546d8dc7c..e617096f3b5 100644 --- a/scene/resources/audio_stream_polyphonic.cpp +++ b/scene/resources/audio_stream_polyphonic.cpp @@ -34,6 +34,9 @@ #include "scene/main/scene_tree.h" #include "servers/audio_server.h" +constexpr uint64_t ID_MASK = 0xFFFFFFFF; +constexpr uint64_t INDEX_SHIFT = 32; + Ref AudioStreamPolyphonic::instantiate_playback() { Ref playback; playback.instantiate(); @@ -252,14 +255,14 @@ AudioStreamPlaybackPolyphonic::ID AudioStreamPlaybackPolyphonic::play_stream(con } AudioStreamPlaybackPolyphonic::Stream *AudioStreamPlaybackPolyphonic::_find_stream(int64_t p_id) { - uint32_t index = p_id >> INDEX_SHIFT; + uint32_t index = static_cast(p_id) >> INDEX_SHIFT; if (index >= streams.size()) { return nullptr; } if (!streams[index].active.is_set()) { return nullptr; // Not active, no longer exists. } - int64_t id = p_id & ID_MASK; + int64_t id = static_cast(p_id) & ID_MASK; if (streams[index].id != id) { return nullptr; } diff --git a/scene/resources/audio_stream_polyphonic.h b/scene/resources/audio_stream_polyphonic.h index 01d0176c44f..b49ed1b7418 100644 --- a/scene/resources/audio_stream_polyphonic.h +++ b/scene/resources/audio_stream_polyphonic.h @@ -60,11 +60,8 @@ public: class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback { GDCLASS(AudioStreamPlaybackPolyphonic, AudioStreamPlayback) - enum { - INTERNAL_BUFFER_LEN = 128, - ID_MASK = 0xFFFFFFFF, - INDEX_SHIFT = 32 - }; + constexpr static uint32_t INTERNAL_BUFFER_LEN = 128; + struct Stream { SafeFlag active; SafeFlag pending_play;