Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in AudioStreamPlaybackPolyphonic where stream IDs returned from play_stream may not work (MSVC) #86054

Conversation

xerothermic06
Copy link

@xerothermic06 xerothermic06 commented Dec 12, 2023

Intended to fix this bug: #86053

The docs state that invoking play_stream on an instance of AudioStreamPlaybackPolyphonic returns an integer ID that can be used to control the volume or stop playback of a given stream, but in GDScript none of these IDs work.

While debugging I noticed that the _find_stream method seems to have platform-dependent behavior because an implicitly typed enum value is used as a bitmask. This line here appears to be the problem:

int64_t id = p_id & ID_MASK;

The usage here seems to be casting ID_MASK undesirably on my system; the result of p_id & ID_MASK is always exactly equal to p_id. My guess is that MSVC is reading 0xFFFFFFFF as -1 and then casting that up to an int64_t also with the value of -1. Added an explicit type to the enum that should remove this ambiguity.

My compiler version is: Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64

Bugsquad edit:

@akien-mga akien-mga changed the title Fix bug in AudioStreamPlaybackPolyphonic where stream IDs returned from play_stream may not work Fix bug in AudioStreamPlaybackPolyphonic where stream IDs returned from play_stream may not work Dec 12, 2023
@akien-mga akien-mga added platform:windows cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Dec 12, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Dec 12, 2023
@xerothermic06 xerothermic06 marked this pull request as ready for review December 16, 2023 18:08
scene/resources/audio_stream_polyphonic.h Outdated Show resolved Hide resolved
@akien-mga akien-mga force-pushed the audiostreamplaybackpolyphonic-bug-mask branch from f15a91f to 28a4c38 Compare July 22, 2024 07:10
@akien-mga akien-mga changed the title Fix bug in AudioStreamPlaybackPolyphonic where stream IDs returned from play_stream may not work Fix bug in AudioStreamPlaybackPolyphonic where stream IDs returned from play_stream may not work (MSVC) Jul 22, 2024
@akien-mga
Copy link
Member

Superseded by #93120 in the end. Thanks for the contribution!

@akien-mga akien-mga closed this Jul 22, 2024
@akien-mga akien-mga added archived and removed cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Jul 22, 2024
@AThousandShips AThousandShips removed this from the 4.3 milestone Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AudioStreamPlaybackPolyphonic: streams with id > 1 cannot be stopped or changed
5 participants