Fix polyphonic audio streams with id > 1 cannot be stopped or changed (MSVC mis-optimization)
This commit is contained in:
parent
e25f3c0d38
commit
67ece3dc63
|
@ -34,6 +34,9 @@
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
|
|
||||||
|
constexpr uint64_t ID_MASK = 0xFFFFFFFF;
|
||||||
|
constexpr uint64_t INDEX_SHIFT = 32;
|
||||||
|
|
||||||
Ref<AudioStreamPlayback> AudioStreamPolyphonic::instantiate_playback() {
|
Ref<AudioStreamPlayback> AudioStreamPolyphonic::instantiate_playback() {
|
||||||
Ref<AudioStreamPlaybackPolyphonic> playback;
|
Ref<AudioStreamPlaybackPolyphonic> playback;
|
||||||
playback.instantiate();
|
playback.instantiate();
|
||||||
|
@ -252,14 +255,14 @@ AudioStreamPlaybackPolyphonic::ID AudioStreamPlaybackPolyphonic::play_stream(con
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioStreamPlaybackPolyphonic::Stream *AudioStreamPlaybackPolyphonic::_find_stream(int64_t p_id) {
|
AudioStreamPlaybackPolyphonic::Stream *AudioStreamPlaybackPolyphonic::_find_stream(int64_t p_id) {
|
||||||
uint32_t index = p_id >> INDEX_SHIFT;
|
uint32_t index = static_cast<uint64_t>(p_id) >> INDEX_SHIFT;
|
||||||
if (index >= streams.size()) {
|
if (index >= streams.size()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!streams[index].active.is_set()) {
|
if (!streams[index].active.is_set()) {
|
||||||
return nullptr; // Not active, no longer exists.
|
return nullptr; // Not active, no longer exists.
|
||||||
}
|
}
|
||||||
int64_t id = p_id & ID_MASK;
|
int64_t id = static_cast<uint64_t>(p_id) & ID_MASK;
|
||||||
if (streams[index].id != id) {
|
if (streams[index].id != id) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,11 +60,8 @@ public:
|
||||||
class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback {
|
class AudioStreamPlaybackPolyphonic : public AudioStreamPlayback {
|
||||||
GDCLASS(AudioStreamPlaybackPolyphonic, AudioStreamPlayback)
|
GDCLASS(AudioStreamPlaybackPolyphonic, AudioStreamPlayback)
|
||||||
|
|
||||||
enum {
|
constexpr static uint32_t INTERNAL_BUFFER_LEN = 128;
|
||||||
INTERNAL_BUFFER_LEN = 128,
|
|
||||||
ID_MASK = 0xFFFFFFFF,
|
|
||||||
INDEX_SHIFT = 32
|
|
||||||
};
|
|
||||||
struct Stream {
|
struct Stream {
|
||||||
SafeFlag active;
|
SafeFlag active;
|
||||||
SafeFlag pending_play;
|
SafeFlag pending_play;
|
||||||
|
|
Loading…
Reference in New Issue