-
Notifications
You must be signed in to change notification settings - Fork 167
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
Suspending audio context for battery usage reasons #317
Comments
fwiw, Gecko does that at the moment (pausing the audio hardware) for the same reasons (for example, some parts of FirefoxOS use the Web Audio API to output system sounds, battery drain is real concern in this context). Our solution works, but has the drawback of not taking latency into account (it's something like pausing the underlying audio stream when we see that only the destination node is present in the graph). I'd rather, as you say, have an explicit API than relying on the behavior of the engine. Random things that need to be specced (maybe there are more):
|
Yeah, the introduced latency or clock-that-doesn't-progress was the problem with trying to do this automatically. You've correctly found the one piece I didn't elaborate on. :) Real-time source nodes - MediaStreams and HTMLMediaElements - should have their output ignored while the AudioContext is paused. ScriptProcessors shouldn't be a problem - they should pause just like the destination node, and events should not be fired. They would not get "queued", per se - but once resume() is called, the events would start firing again as time progresses. I don't think we should drain the buffers, and yes, the playback would continue from the last played frame. And yes, for windowing purposes, the last audio data played back would be retained. |
Well, I think we agree, then. Any other thoughts from actual users of the API instead of implementers :-) ? |
:) (Note there's an implicit users-of-API ask here from us, since this came On Mon, May 5, 2014 at 3:42 PM, Paul ADENOT notifications@github.comwrote:
|
This looks very similar to issue #72, which I opened for similar reasons. |
Hmm. There are three related but somewhat orthogonal things wrapped up here:
Jer, you wrapped the first and second together; I actually would like to explicitly enable audio apps to ask for exclusive access on systems that need exclusive access for better latency characteristics (e.g. Windows!), and I see how that would tie together with #2. I only list #2 and #3 separately because I think #2 can quickly imply pausing PARTS of the audio graph - for example, if a gamer hits Pause, the game sound may pause but the menu popped up frequently has UI feedback audio still active. That's much harder to explain (separate timelines for each audio pathway), unless we just say that's a multiple-AudioContext scenario. I'd like to explicitly avoid doing this, and keep one "currentTime" for each AudioContext. Perhaps what we need here is
WDYT? |
(1) is necessary. |
Agreed.
So a “suspended” and a “resumed” event (or some equivalent name)? Sounds fine to me.
Why should this particular use case be exposed through API? Would a web page try “regular mode”, and if that fails retry with “exclusive mode”? Or would web developers start to always request “exclusive mode” because that “works better on windows”? Maybe I’m missing something about what an “exclusive mode” to an AudioContext would allow UAs on Windows to provide.
Agreed. -Jer |
On 16/06/2014 19:38, Jer Noble wrote:
It's a mode where an application takes exclusive control of the audio |
Should additionally provide "release" to forcibly release unneeded AudioContexts. |
Will these methods be available for OfflineAudioContexts, too? Please see my comment on #21 |
This has a race somewhere, so we disable it for now. The real fix will come from the Web Audio API Suspend API [0] [0]: WebAudio/web-audio-api#317
WebAudio is adding a suspend()/resume() API: WebAudio/web-audio-api#361 WebAudio/web-audio-api#317 The specification is here: http://webaudio.github.io/web-audio-api/#the-audiocontext-interface http://webaudio.github.io/web-audio-api/#widl-AudioContext-suspend-Promise http://webaudio.github.io/web-audio-api/#widl-AudioContext-resume-Promise BUG=420106 TESTS=new layout tests added Review URL: https://codereview.chromium.org/697603003 git-svn-id: svn://svn.chromium.org/blink/trunk@186253 bbb929c8-8fbe-4397-9dbb-9b2b20218538
This has a race somewhere, so we disable it for now. The real fix will come from the Web Audio API Suspend API [0] [0]: WebAudio/web-audio-api#317 UltraBlame original commit: a71337656d0cb61f6cacce8714bea7094ad36000
This has a race somewhere, so we disable it for now. The real fix will come from the Web Audio API Suspend API [0] [0]: WebAudio/web-audio-api#317 UltraBlame original commit: a71337656d0cb61f6cacce8714bea7094ad36000
This has a race somewhere, so we disable it for now. The real fix will come from the Web Audio API Suspend API [0] [0]: WebAudio/web-audio-api#317 UltraBlame original commit: a71337656d0cb61f6cacce8714bea7094ad36000
We've run in to a significant request to reduce battery consumption. In short, we need to be able to suspend the audio hardware device usage.
Unfortunately, given the current design, we have no way of doing this; the best we can tell users is "drop all references to AudioContexts", but even then, until garbage collection happens there's no guarantee the hardware device context will be freed up (enabling it to suspend and stop consuming power).
Raymond and I have discussed this in some detail, and I think our preferred option is that we provide two methods on the AudioContext:
...that will put the system into suspension (meaning, the AudioContext currentTime stops progressing, all sound output is paused, and the audio hardware can power down), and asynchronously wake it up again and resuming processing (which is an asynchronous operation, and may take some amount of [real] time until the audio system has resumed processing data).
This takes away the unpredictability of when the audio system shuts down, but also lets us account for the latency hiccup in restarting.
The text was updated successfully, but these errors were encountered: