Skip to content

Return the length of the playing stream for AudioStreamRandomizer #105952

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

Merged

Conversation

JulianHeuser
Copy link
Contributor

Fixes #105929
Fixes #104684

@JulianHeuser JulianHeuser requested a review from a team as a code owner April 30, 2025 15:27
@Mickeon Mickeon added this to the 4.5 milestone Apr 30, 2025
@Mickeon
Copy link
Member

Mickeon commented Apr 30, 2025

We should probably question what get_length() should generally return for AudioStreamRandomizer. (see #105954 💦). This looks ideal specifically for AudioStreamInteractive, but it may be entirely unexpected when fetching the length without intending to play the AudioStreamRandomizer first.

@Mickeon

This comment was marked as resolved.

@JulianHeuser
Copy link
Contributor Author

JulianHeuser commented Apr 30, 2025

Either way, can you actually confirm this fixes #104684 ?

Yes, I've tested it and it plays everything in sequence as expected, so it's definitely caused by the same issue.

I see the problem though - It would be a bit unclear if get_length changes its value based on the state of the stream, but it also doesn't make sense for it to be static on streams that can have variable length. The same issue is present for AudioStreamInteractive. I think for consistency, it makes more sense to return the length of the currently playing stream rather than the max length, since there are a lot of cases where users will need to use streams of variable length with AudioStreamInteractive. If someone wants to get the max length of all streams, they can do that in code, or we can make a helper function for the types of streams that could use it.

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in the audio meeting, we prefer this solution to the one returning the length of the longest stream.

@Mickeon Mickeon requested a review from adamscott June 10, 2025 17:46
@akien-mga akien-mga modified the milestones: 4.5, 3.7 Jun 10, 2025
@akien-mga akien-mga merged commit 3dd03fb into godotengine:master Jun 11, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

AudioStreamInteractive treats AudioStreamRandomizer as if it has no length. AudioStreamPlaylist ignores AudioStreamRandomizer
4 participants