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

Implement AudioContext suspend() #78

Closed
raub opened this issue Mar 17, 2018 · 5 comments
Closed

Implement AudioContext suspend() #78

raub opened this issue Mar 17, 2018 · 5 comments

Comments

@raub
Copy link
Contributor

raub commented Mar 17, 2018

Spec states that there is a way to temporarily suspend rendering. However, in LabSound you can only start it and never stop, APIwise. Actual implementation of the internal AudioDestination has the needed stop() method, but it is hidden from the exported interfaces. Specifically, AudioDestinationNode already has only the startRendering() and no stopRendering(). Is there a problem with letting people call it?

@meshula
Copy link
Member

meshula commented Apr 16, 2018

Further note: AudioContext is supposed to emit a statechanged event when starting, stopping, and deleting the context, and there's supposed to be a status method that reports suspended, running, or closed, when the state has changed.

https://webaudio.github.io/web-audio-api/

@meshula
Copy link
Member

meshula commented Jan 17, 2019

One possible implementation; will stop at buffer resolution. avaer@221e1e2

@xioxin
Copy link
Contributor

xioxin commented May 22, 2021

The pause feature reduces battery consumption when idle.
I am integrating LabSound into Flutter and it is important for mobile to save power.
By the way, how to release the AudioContext, I didn't find the "close" method.

@meshula meshula changed the title AudioContext has no suspend() Implement AudioContext suspend() May 22, 2021
@meshula
Copy link
Member

meshula commented May 22, 2021

Thank you for bumping this issue.

Destructing an AudioContext will release system resources, but does not match the requirements of close. I created a new issue here: #154

For reference, documentation of suspend is here: https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/suspend

and the summary is:

  • The suspend() method of the AudioContext Interface suspends the progression of time in the audio context, temporarily halting audio hardware access

@meshula
Copy link
Member

meshula commented May 24, 2021

As of c720c5e suspend and resume now pause and resume processing. Time stops progressing during suspend, and resumes properly. CPU utilization falls during suspend. Please feel free to reopen if there are any issues.

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