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

AudioStreamPlayer changes stream_paused internally #65743

Open
Tracked by #76797
Grandro opened this issue Sep 13, 2022 · 2 comments
Open
Tracked by #76797

AudioStreamPlayer changes stream_paused internally #65743

Grandro opened this issue Sep 13, 2022 · 2 comments

Comments

@Grandro
Copy link

Grandro commented Sep 13, 2022

Godot version

3.5.stable

System information

Windows 10

Issue description

AudioStreamPlayer changes the stream_paused property internally when NOTIFICATION_PAUSED and NOTIFICATION_UNPAUSED is being propagated. While it seems to be desired behaviour to pause the AudioStreamPlayer if the pause_mode doesn't allow it to process further if the SceneTree is paused, the information if it was paused before the SceneTree was paused is lost. This way you cannot revert to the previous value after the SceneTree is unpaused again (Currently stream_paused is always set to false).

if (p_what == NOTIFICATION_PAUSED) {
	if (!can_process()) {
		// Node can't process so we start fading out to silence
		set_stream_paused(true);
	}
}

if (p_what == NOTIFICATION_UNPAUSED) {
	set_stream_paused(false);
}

audio_stream_player.cpp
(I wasn't able to find out how to quote the actual code)

This makes setting the stream_paused property manually very unreliable to use if you also want to pause your game and you are left with no good option to pause a AudioStreamPlayer temporarily.

Steps to reproduce

  1. Create a new project
  2. Add a AudioStreamPlayer to your scene
  3. Call play() and set stream_paused to true
  4. Pause the SceneTree with get_tree().paused = true
  5. Unpause the SceneTree with get_tree().paused = false
  6. stream_paused will be set to false again

Minimal reproduction project

No response

@Mickeon
Copy link
Contributor

Mickeon commented Sep 13, 2022

I mentioned this behaviour here: #65367.

It is actually intentional, and is still present in the alpha builds, but to quote myself:

This, from the user's perspective, makes setting the stream_paused property manually a bit more unreliable than it already was before. Maybe something about it can be done another time?

The reason for this is, as you have noticed, is because stream_paused is used internally by the engine for those kind of occasions described above.
There should probably be two variables handling this. One of them is internal, the other (stream_paused) is exposed to the user.

@Grandro
Copy link
Author

Grandro commented Sep 13, 2022

Pausable_Audio.zip
I have created a workaround in GDScript where stream_paused is set accordingly again after the SceneTree is unpaused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants