@@ -709,10 +709,12 @@ Each {{BaseAudioContext}} has a unique
709709media element event task source</a>.
710710Additionally, a {{BaseAudioContext}} has several private slots <dfn attribute
711711for="BaseAudioContext">[[rendering thread state]]</dfn> and <dfn attribute
712- for="BaseAudioContext">[[control thread state]]</dfn> that take values from
713- {{AudioContextState}}, and that are both initially set to <code>"suspended"
714- </code>, and a private slot <dfn attribute for="BaseAudioContext">
715- [[render quantum size]]</dfn> that is an unsigned integer.
712+ for="BaseAudioContext">[[control thread state]]</dfn> that take values
713+ from {{AudioContextState}}, and that are both initially set to <code>"suspended"
714+ </code>, <dfn attribute for="BaseAudioContext">[[interrupt end return state]]
715+ </dfn> that also take values from {{AudioContextState}} and is initially set to
716+ `null` and a private slot <dfn attribute for="BaseAudioContext">[[render quantum
717+ size]]</dfn> that is an unsigned integer.
716718
717719<pre class="idl">
718720enum AudioContextState {
@@ -1549,6 +1551,8 @@ Constructors</h4>
15491551
15501552 1. Set a {{[[rendering thread state]]}} to <code>suspended</code> on
15511553 |context|.
1554+
1555+ 1. Set {{[[interrupt end return state]]}} to `null` on |context|.
15521556
15531557 1. Let |messageChannel| be a new {{MessageChannel}}.
15541558
@@ -1980,15 +1984,19 @@ Methods</h4>
19801984 returning <var>promise</var>.
19811985
19821986 1. Set {{[[suspended by user]]}} to <code>false</code>.
1987+
1988+ 1. If the context's {{BaseAudioContext/state}} attribute is
1989+ "{{AudioContextState/suspended}}" and the context's
1990+ {{[[control thread state]]}} is
1991+ "{{AudioContextState/interrupted}}", then:
19831992
1984- 1. If the {{[[control thread state]]}} on the {{AudioContext}} is
1985- <code>suspended</code> and there is an ongoing
1986- [=interruption=]:
1987-
1988- 1. Queue a media element task</a> to execute the following steps:
1993+ 1. <a>Queue a media element task</a> to execute the following steps:
19891994
19901995 1. Set the {{BaseAudioContext/state}} attribute of the
19911996 {{AudioContext}} to "{{AudioContextState/interrupted}}".
1997+
1998+ 1. Set the {{[[interrupt end return state]]}} slot to
1999+ "{{AudioContextState/running}}".
19922000
19932001 1. [=Queue a media element task=] to [=fire an event=] named
19942002 {{BaseAudioContext/statechange}} at the {{AudioContext}}.
@@ -2105,14 +2113,19 @@ Methods</h4>
21052113
21062114 1. Attempt to <a>release system resources</a>.
21072115
2108- 2. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to <code>suspended</code>.
2116+ 1. If the {{[[rendering thread state]]}} on the {{AudioContext}} is
2117+ "{{AudioContextState/interrupted}}", <a>queue a media element
2118+ task</a> to set the {{[[interrupt end return state]]}} slot to
2119+ "{{AudioContextState/suspended}}".
21092120
2110- 3. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
2111- queue a media element task</a> to execute the following steps:
2121+ 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
2122+ "{{AudioContextState/suspended}}".
2123+
2124+ 1. <a>Queue a media element task</a> to execute the following steps:
21122125
21132126 1. Resolve <var>promise</var>.
21142127
2115- 2 . If the {{BaseAudioContext/state}}
2128+ 1 . If the {{BaseAudioContext/state}}
21162129 attribute of the {{AudioContext}} is not already "{{AudioContextState/suspended}}":
21172130
21182131 1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to "{{AudioContextState/suspended}}".
@@ -11993,70 +12006,69 @@ to halt audio playback for an {{AudioContext}}. For example, The user agent may
1199312006create an interruption when another application requests exclusive access to the
1199412007audio output hardware.
1199512008
11996- When an [=interruption=] happens, the user agent must <a>queue a control message</a>
12009+ When an [=interruption=] happens, the user agent MUST <a>queue a control message</a>
1199712010to interrupt the {{AudioContext}}.
1199812011
1199912012Running a <a>control message</a> to <dfn attribute for="AudioContext"
1200012013lt="interruption-start">interrupt an {{AudioContext}}</dfn> |context|
1200112014means running these steps on the <a>rendering thread</a>:
1200212015
12003- 1. If the |context|'s {{[[rendering thread state]]}} is <code>closed</code>
12004- or <code>interrupted</code>:
12005-
12006- 1. Abort these steps.
12016+ 1. If the |context|'s {{[[rendering thread state]]}} is
12017+ {{AudioContextState/closed}} or {{AudioContextState/interrupted}}, abort
12018+ these steps.
1200712019
12008120201. If the |context|'s {{[[rendering thread state]]}} is
12009- <code>running</code> :
12021+ {{AudioContextState/running}} :
1201012022
1201112023 1. Attempt to <a>release system resources</a>.
1201212024
1201312025 1. [=Queue a media element task=] to execute the following steps:
1201412026
1201512027 1. Set the |context|'s {{[[control thread state]]}} to
12016- <code>interrupted</code>.
12028+ {{AudioContextState/interrupted}}.
12029+
12030+ 1. Set the |context|'s {{[[interrupt end return state]]}} slot to
12031+ "{{AudioContextState/running}}".
1201712032
1201812033 1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
1201912034 |context|.
1202012035
12021120361. If the |context|'s {{[[rendering thread state]]}} is
12022- <code>suspended</code> :
12037+ {{AudioContextState/suspended}} :
1202312038
1202412039 1. [=Queue a media element task=] to execute the following steps:
1202512040
1202612041 1. Set the |context|'s {{[[control thread state]]}} to
12027- <code>interrupted</code>.
12042+ {{AudioContextState/interrupted}}.
12043+
12044+ 1. Set the |context|'s {{[[interrupt end return state]]}} slot to
12045+ "{{AudioContextState/suspended}}".
1202812046
12029120471. Set the |context|'s {{[[rendering thread state]]}} to
12030- <code>interrupted</code> .
12048+ {{AudioContextState/interrupted}} .
1203112049
12032- Note: If the {{AudioContext}} is <code>suspended</code> a
12050+ Note: If the {{AudioContext}} is {{AudioContextState/suspended}} a
1203312051{{BaseAudioContext/statechange}} event is not fired for privacy reasons to avoid
1203412052over-sharing user activity - e.g. when a phone call comes in or when the screen
1203512053gets locked.
1203612054
12037- When an [=interruption=] ends, the user agent must <a>queue a control message</a>
12055+ When an [=interruption=] ends, the user agent MUST <a>queue a control message</a>
1203812056to <dfn attribute for="AudioContext" lt="interruption-end">end the
1203912057{{AudioContext}} interruption</dfn>.
1204012058
12041- <dfn lt="linear PCM">Linear pulse code modulation</dfn>
12042-
1204312059Running a <a>control message</a> to end an {{AudioContext}} |context|
1204412060[=interruption=] means running these steps on the <a>rendering thread</a>:
1204512061
12046120621. If the |context|'s {{[[rendering thread state]]}} is not
12047- <code>interrupted</code>:
12063+ {{AudioContextState/interrupted}}, abort these steps.
1204812064
12049- 1. Abort these steps.
12050-
12051- 1. If the |context|'s {{[[rendering thread state]]}} was
12052- <code>running</code> before the [=interruption=] or if the the
12053- |context|'s {{[[rendering thread state]]}} was <code>suspended</code>
12054- and {{AudioContext/resume}} was called during the [=interruption=]:
12065+ 1. If the |context|'s {{[[interrupt end return state]]}} is
12066+ "{{AudioContextState/running}}":
1205512067
1205612068 1. Attempt to <a href="#acquiring">acquire system resources</a>.
1205712069
1205812070 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
12059- <code>running</code> .
12071+ "{{AudioContextState/running}}" .
1206012072
1206112073 1. Start <a href="#rendering-loop">rendering the audio graph</a>.
1206212074
@@ -12066,13 +12078,13 @@ Running a <a>control message</a> to end an {{AudioContext}} |context|
1206612078 is not already "{{AudioContextState/running}}":
1206712079
1206812080 1. Set the |context|'s {{[[control thread state]]}} to
12069- <code>running</code> .
12081+ "{{AudioContextState/running}}" .
1207012082
1207112083 1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
1207212084 |context|.
1207312085
12074- 1. If the |context|'s {{[[rendering thread state]]}} was
12075- <code>suspended</code> before the [=interruption=]:
12086+ 1. If the |context|'s {{[[interrupt end return state]]}} is
12087+ "{{AudioContextState/suspended}}"
1207612088
1207712089 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
1207812090 <code>suspended</code>.
@@ -12082,6 +12094,8 @@ Running a <a>control message</a> to end an {{AudioContext}} |context|
1208212094 1. Set the |context|'s {{[[control thread state]]}} to
1208312095 <code>suspended</code>.
1208412096
12097+ 1. Set the |context|'s {{[[interrupt end return state]]}} to `null`.
12098+
1208512099<h3 id="error-handling-on-a-running-audio-context">
1208612100 Handling an error from System Audio Resources on the {{AudioContext}}</h3>
1208712101
0 commit comments