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

AudioContext.onerror #2580

Merged
merged 18 commits into from
Jul 10, 2024
199 changes: 158 additions & 41 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ window.addEventListener('load', (event) => {
ListAmendments("c2400", "Proposed Addition", "change-list-2400");
ListAmendments("c2512", "Proposed Addition", "change-list-2512");
ListAmendments("c2450", "Proposed Addition", "change-list-2450");
ListAmendments("c2567", "Proposed Addition", "change-list-2567");
});
</script>
<style>
Expand Down Expand Up @@ -1693,9 +1694,11 @@ enum AudioSinkType {
<a href="https://github.com/WebAudio/web-audio-api/issues/2444">Issue 2444
</a> Add AudioRenderCapacity Interface <br>
<a href="https://github.com/WebAudio/web-audio-api/issues/2400" id="c2400-2">
Issue 2400</a> Access to a different output device
Issue 2400</a> Access to a different output device <br>
<a href="https://github.com/WebAudio/web-audio-api/issues/2567" id="c2567-1">
Issue 2567</a>. Device-related error reporting via AudioContext
<div class="amendment-buttons"></div>
<del cite="#c2444 #c2400">
<del cite="#c2444 #c2400 #c2567">
<xmp class="idl extract" data-no-idl>
[Exposed=Window]
interface AudioContext : BaseAudioContext {
Expand All @@ -1714,7 +1717,7 @@ enum AudioSinkType {
};
</xmp>
</del>
<ins cite="#c2444 #2400">
<ins cite="#c2444 #2400 #2567">
<xmp class="idl">
[Exposed=Window]
interface AudioContext : BaseAudioContext {
Expand All @@ -1724,6 +1727,7 @@ enum AudioSinkType {
[SecureContext] readonly attribute (DOMString or AudioSinkInfo) sinkId;
[SecureContext] readonly attribute AudioRenderCapacity renderCapacity;
attribute EventHandler onsinkchange;
attribute EventHandler onerror;
AudioTimestamp getOutputTimestamp ();
Promise<undefined> resume ();
Promise<undefined> suspend ();
Expand Down Expand Up @@ -1943,53 +1947,88 @@ Constructors</h4>
Sending a <a>control message</a> to start processing means
executing the following steps:

<div class="addition proposed" id="c2400-5">
<span class="marker">Proposed Addition</span><br>
<a href="https://github.com/WebAudio/web-audio-api/issues/2400">Issue
2400</a> Access to a different output device
<div class="amendment-buttons"></div>
<del cite=#2400>
1. Attempt to <a href="#acquiring">acquire system resources</a>.
In case of failure, abort the following steps.

3. Set the {{[[rendering thread state]]}} to <code>running</code> on the {{AudioContext}}.
<div class="addition proposed">
<div class="addition proposed" id="c2400-5" style="border:0; margin:0; padding:0">
hoch marked this conversation as resolved.
Show resolved Hide resolved
<span class="marker">Proposed Addition
<a href="https://github.com/WebAudio/web-audio-api/issues/2400">Issue 2400</a>.
</span>
Access to a different output device
<div class="amendment-buttons"></div>
hoch marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class="addition proposed" id="c2567-2" style="border:0; margin:0; padding:0">
<span class="marker">Proposed Addition
<a href="https://github.com/WebAudio/web-audio-api/issues/2567">Issue 2567</a>.
</span>
Device-related error reporting via AudioContext
<div class="amendment-buttons"></div>
</div>

1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
queue a media element task</a> to execute the following steps:
<del cite="#2400 #2567">
1. Attempt to <a href="#acquiring">acquire system resources</a>.
In case of failure, abort the following steps.

1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to "{{AudioContextState/running}}".
3. Set the {{[[rendering thread state]]}} to <code>running</code> on the {{AudioContext}}.
hoch marked this conversation as resolved.
Show resolved Hide resolved

1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
queue a media element task</a> to <a spec="dom" lt="fire an event">fire an event
</a> named {{BaseAudioContext/statechange}} at the {{AudioContext}}.
</del>
<ins cite=#2400>
1. Attempt to <a href="#acquiring">acquire system resources</a> to use a
following audio output device based on {{AudioContext/[[sink ID]]}} for
rendering:
queue a media element task</a> to execute the following steps:

* The default audio output device for the empty string.
* A audio output device identified by {{AudioContext/[[sink ID]]}}.

In case of failure, abort the following steps.
1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to "{{AudioContextState/running}}".

1. Set the {{[[rendering thread state]]}} to <code>running</code> on the
{{AudioContext}}.
1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
queue a media element task</a> to <a spec="dom" lt="fire an event">fire an event
</a> named {{BaseAudioContext/statechange}} at the {{AudioContext}}.
hoch marked this conversation as resolved.
Show resolved Hide resolved
</del>
<ins cite="#2400 #2567">
1. Attempt to <a href="#acquiring">acquire system resources</a> to use a
hoch marked this conversation as resolved.
Show resolved Hide resolved
following audio output device based on {{AudioContext/[[sink ID]]}} for
rendering:

1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
Queue a media element task</a> to execute the following steps:
* The default audio output device for the empty string.
* A audio output device identified by {{AudioContext/[[sink ID]]}}.

Upon failure of resource acquisition,
<a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
queue a media element task</a> to
<a spec="dom" lt="fire an event">fire an event</a> named
{{AudioContext/error}} at the {{AudioContext}}, and abort
the following steps.
hoch marked this conversation as resolved.
Show resolved Hide resolved

1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}}
to "{{AudioContextState/running}}".
1. Set the {{[[rendering thread state]]}} to <code>running</code> on the
hoch marked this conversation as resolved.
Show resolved Hide resolved
{{AudioContext}}.

1. <a spec="dom" lt="fire an event">Fire an event</a> named
{{BaseAudioContext/statechange}} at the {{AudioContext}}.
</ins>
1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
Queue a media element task</a> to execute the following steps:
hoch marked this conversation as resolved.
Show resolved Hide resolved

1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}}
to "{{AudioContextState/running}}".

1. <a spec="dom" lt="fire an event">Fire an event</a> named
{{BaseAudioContext/statechange}} at the {{AudioContext}}.
</ins>

</div>
</div>

<div class="proposed addition" id="c2567-3">
<span class="marker">Proposed Addition
<a href="https://github.com/WebAudio/web-audio-api/issues/2567">Issue 2567</a>.
</span>
Device-related error reporting via AudioContext
<div class="amendment-buttons"></div>
<del>
Note: It is unfortunately not possible to programatically notify authors
that the creation of the {{AudioContext}} failed. User-Agents are
encouraged to log an informative message if they have access to a logging
mechanism, such as a developer tools console.
</del>
<ins>
NOTE: In cases where an AudioContext is constructed with no
hoch marked this conversation as resolved.
Show resolved Hide resolved
arguments and resource acquisition fails, the User-Agent must
attempt to silently render the audio graph using a mechanism that
emulates an audio output device.
hoch marked this conversation as resolved.
Show resolved Hide resolved
</ins>
</div>

</div>

<div class="addition proposed" id="c2456-2">
Expand Down Expand Up @@ -2086,10 +2125,8 @@ Attributes</h4>
2444</a>.
</span>
Add AudioRenderCapacity Interface
<div class="amendment-buttons">
Buttons here
</div>
<ins cite=#c2444>
<div class="amendment-buttons"></div>
<ins cite=#c2444>
: <dfn>renderCapacity</dfn>
::
Returns an {{AudioRenderCapacity}} instance associated with
Expand Down Expand Up @@ -2121,7 +2158,31 @@ Attributes</h4>
is available to check the readiness of the initial output device.

</ins>
</dl>
</div>

<div class="proposed addition" id="c2567-4">
<span class="marker">Proposed Addition
<a href="https://github.com/WebAudio/web-audio-api/issues/2567">Issue 2567</a>.
</span>
Device-related error reporting via AudioContext
<div class="amendment-buttons"></div>
hoch marked this conversation as resolved.
Show resolved Hide resolved
<ins cite=#2567>
: <dfn>onerror</dfn>
::
An [=event handler=] for any <dfn event>error</dfn> {{Event}} dispatched from an
hoch marked this conversation as resolved.
Show resolved Hide resolved
{{AudioContext}}. The user agent can dispatch this event in the
following cases:

* The process of initializing and activiating the selected audio
device encounters an issue.
* The audio output from a {{AudioContextState/running}}
{{AudioContext}} unexpectedly interrupted or the device is
disconnected.

</ins>
</div>

</dl>

<h4 id="AudioContext-methods">
Methods</h4>
Expand Down Expand Up @@ -12839,6 +12900,62 @@ running the algorithm for an {{AudioNode}}, using an <a>input
buffer</a> and the value(s) of the {{AudioParam}}(s) of this
{{AudioNode}} as the input for this algorithm.


<div class="addition proposed" id="c2567-5">
<span class="marker">Proposed addition
<a href="https://github.com/WebAudio/web-audio-api/issues/2567">Issue 2567</a>.
</span>
Device-related error reporting via AudioContext
<div class="amendment-buttons"></div>
<ins>

<h3 id="error-handling-on-a-running-audio-context">
Handling an error from System Audio Resources on the {{AudioContext}}</h3>
hoch marked this conversation as resolved.
Show resolved Hide resolved

The <a>rendering thread</a> performs the following steps in the event of an
audio system resource error.

1. If the {{[[rendering thread state]]}} of the {{AudioContext}} is
hoch marked this conversation as resolved.
Show resolved Hide resolved
<code>running</code>.

1. Attempt to <a>release system resources</a>.

1. Set {{[[rendering thread state]]}} of the {{AudioContext}} to
<code>suspended</code>.

1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
Queue a media element task</a> to execute the following steps:

1. <a spec="dom" lt="fire an event">Fire an event</a> named {{AudioContext/error}} at the
{{AudioContext}}.

1. Set {{[[suspended by user]]}} of the {{AudioContext}} to <code>false</code>.

1. Set {{[[control thread state]]}} of the {{AudioContext}} to <code>suspended</code>.

1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to
"{{AudioContextState/suspended}}".

1. <a spec="dom" lt="fire an event">Fire an event</a> named
{{BaseAudioContext/statechange}} at the {{AudioContext}}.

1. Abort these steps.

1. If the {{[[rendering thread state]]}} of the {{AudioContext}} is
<code>suspended</code>.

1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
Queue a media element task</a> to execute the following steps:

1. <a spec="dom" lt="fire an event">Fire an event</a> named {{AudioContext/error}} at the
{{AudioContext}}.
hoch marked this conversation as resolved.
Show resolved Hide resolved

Note: An example of system audio resource errors would be when an external or wireless audio
device becomes disconnected during the active rendering of the AudioContext.
hoch marked this conversation as resolved.
Show resolved Hide resolved
hoch marked this conversation as resolved.
Show resolved Hide resolved

</ins>
</div>

<h3 id="unloading-a-document">Unloading a document</h3>
Additional <a href=
"https://html.spec.whatwg.org/#unloading-document-cleanup-steps">unloading
Expand Down
Loading