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

Add support for Suspend/WakeupFromSuspend in wwise_runtime_manager #84

Open
ak-slongchamps opened this issue Oct 11, 2023 · 2 comments
Open

Comments

@ak-slongchamps
Copy link

Wwise integration version

wwise-2023.1.0-beta-for-godot-4.1.1-stable-2.0.2

System information

Any

Issue description

See how in the Integration Demo sample packaged with the Wwise SDK the engine is put to a suspended state in response to window minimize and restore: the platform-specific WM handlers call IntegrationDemo::Pause and IntegrationDemo::Resume, which respectively call AK::SoundEngine::Suspend(false) and AK::SoundEngine::WakeupFromSuspend().

This can be accompanied by posting a pause all and resume all event, but this is typically left to the client (because events are project specific).

At the moment, I don't see any window minimized or restored NOTIFICATION_WM_* constant in Godot 4.1 (looking here: https://docs.godotengine.org/en/stable/classes/class_node.html#constants).
At least, NOTIFICATION_APPLICATION_PAUSED and NOTIFICATION_APPLICATION_RESUMED would apply to Android, but suspending on focus out might prove too constraining.

Steps to reproduce

Minimize or restore a window: see that the sound keeps playing.

Minimal reproduction project

N/A

@alessandrofama
Copy link
Owner

I've explored this during the update to Godot 4.2, which finally allowed the addition of Android support, enabling me to test its behavior on that platform.

I also observed that the focus in/out behavior is quite restrictive, particularly when connected to and interacting with the authoring app.
For desktop platforms, I've introduced a suspend_on_focus_loss setting that users can activate in the Project Settings. When activated, NOTIFICATION_APPLICATION_FOCUS_OUT and NOTIFICATION_APPLICATION_FOCUS_IN will trigger calls to AK::SoundEngine::Suspend and AK::SoundEngine::WakeupFromSuspend, respectively.

This setting provides the option to customize the suspend behavior in the editor for both debug and release builds.
If deactivated, users still have the possibility to control the behavior themselves, either by calling suspend and wakeup_from_suspend in the Wwise singleton, or by calling pause and resume in the WwiseRuntimeManager.

On Android, the suspend and wakeup functions will be called by default on NOTIFICATION_APPLICATION_PAUSED and NOTIFICATION_APPLICATION_UNPAUSED (currently only implemented on Android).

When looking at Godot's windows display server, I can't find any notification handling for window minimize and restore. This is something I can investigate with the Godot community in the future.

@ak-slongchamps
Copy link
Author

Thank you for this investigation!

focus in/out behavior is quite restrictive, particularly when connected to and interacting with the authoring app.

Definitely agree here: it's a lot less useful to bind this on focus instead of minimize-restore state, but without the notification I understand that's the best you can do. It doesn't look too hard to add it in Godot, hopefully this is something that gets added eventually!

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

No branches or pull requests

2 participants