Re: AudioContext suspend/resume/release

On Aug 29, 2014 12:30 PM, "Chris Wilson" <cwilso@google.com> wrote:
>
> Hello TAG!
>
> We're discussing an issue in the Web Audio API (
https://github.com/WebAudio/web-audio-api/issues/317) of the need for
suspending and resuming AudioContexts for power consumption reasons.
Alongside this, we've found the need to be able to release AudioContexts
completely - in short, AudioContexts may be consuming system resources, and
we need a way for developers to definitively state "I'm done with this
now", aside from just releasing references and hoping the GC takes care of
it.
>
> The current proposal is to add a method to the AudioContext interface:
>
> Promise release ();

This is a general pattern that we have seen in many APIs. Canvas is another
such example. Blobs and WebSockets are other.

I believe there is a bit of prior art in calling the function .close().
This is what Blob and WebSocket calls it (though WebSocket's close() does
other things too).

What is the purpose of returning a Promise? I don't particularly mind, but
given that this is a function to save resources, why incur the cost of an
extra object creation?

/ Jonas

>
> Releases the audio context, including any system resources used by it.
This will not automatically release all AudioContext-created objects,
unless other references have been released as well; however, it will
forcibly release any system resources that might prevent additional
AudioContexts from being created and used. The promise resolves when any
AudioContext-creation-blocking resources have been released.
>
> Do you have any concerns over this pattern?
>
> Thanks,
> -Chris
>

Received on Saturday, 27 September 2014 20:43:45 UTC