@@ -708,10 +708,12 @@ Each {{BaseAudioContext}} has a unique
708
708
media element event task source</a>.
709
709
Additionally, a {{BaseAudioContext}} has several private slots <dfn attribute
710
710
for="BaseAudioContext">[[rendering thread state]]</dfn> and <dfn attribute
711
- for="BaseAudioContext">[[control thread state]]</dfn> that take values from
712
- {{AudioContextState}}, and that are both initially set to <code>"suspended"
713
- </code>, and a private slot <dfn attribute for="BaseAudioContext">
714
- [[render quantum size]]</dfn> that is an unsigned integer.
711
+ for="BaseAudioContext">[[control thread state]]</dfn> that take values
712
+ from {{AudioContextState}}, and that are both initially set to <code>"suspended"
713
+ </code>, <dfn attribute for="BaseAudioContext">[[interrupt end return state]]
714
+ </dfn> that also take values from {{AudioContextState}} and is initially set to
715
+ `null` and a private slot <dfn attribute for="BaseAudioContext">[[render quantum
716
+ size]]</dfn> that is an unsigned integer.
715
717
716
718
<pre class="idl">
717
719
enum AudioContextState {
@@ -1549,6 +1551,8 @@ Constructors</h4>
1549
1551
1550
1552
1. Set a {{[[rendering thread state]]}} to <code>suspended</code> on
1551
1553
|context|.
1554
+
1555
+ 1. Set {{[[interrupt end return state]]}} to `null` on |context|.
1552
1556
1553
1557
1. Let |messageChannel| be a new {{MessageChannel}}.
1554
1558
@@ -1983,15 +1987,19 @@ Methods</h4>
1983
1987
returning <var>promise</var>.
1984
1988
1985
1989
1. Set {{[[suspended by user]]}} to <code>false</code>.
1990
+
1991
+ 1. If the context's {{BaseAudioContext/state}} attribute is
1992
+ "{{AudioContextState/suspended}}" and the context's
1993
+ {{[[control thread state]]}} is
1994
+ "{{AudioContextState/interrupted}}", then:
1986
1995
1987
- 1. If the {{[[control thread state]]}} on the {{AudioContext}} is
1988
- <code>suspended</code> and there is an ongoing
1989
- [=interruption=]:
1990
-
1991
- 1. Queue a media element task</a> to execute the following steps:
1996
+ 1. <a>Queue a media element task</a> to execute the following steps:
1992
1997
1993
1998
1. Set the {{BaseAudioContext/state}} attribute of the
1994
1999
{{AudioContext}} to "{{AudioContextState/interrupted}}".
2000
+
2001
+ 1. Set the {{[[interrupt end return state]]}} slot to
2002
+ "{{AudioContextState/running}}".
1995
2003
1996
2004
1. [=Queue a media element task=] to [=fire an event=] named
1997
2005
{{BaseAudioContext/statechange}} at the {{AudioContext}}.
@@ -2104,14 +2112,19 @@ Methods</h4>
2104
2112
2105
2113
1. Attempt to <a>release system resources</a>.
2106
2114
2107
- 2. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to <code>suspended</code>.
2115
+ 1. If the {{[[rendering thread state]]}} on the {{AudioContext}} is
2116
+ "{{AudioContextState/interrupted}}", <a>queue a media element
2117
+ task</a> to set the {{[[interrupt end return state]]}} slot to
2118
+ "{{AudioContextState/suspended}}".
2108
2119
2109
- 3. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
2110
- queue a media element task</a> to execute the following steps:
2120
+ 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
2121
+ "{{AudioContextState/suspended}}".
2122
+
2123
+ 1. <a>Queue a media element task</a> to execute the following steps:
2111
2124
2112
2125
1. Resolve <em>promise</em>.
2113
2126
2114
- 2 . If the {{BaseAudioContext/state}}
2127
+ 1 . If the {{BaseAudioContext/state}}
2115
2128
attribute of the {{AudioContext}} is not already "{{AudioContextState/suspended}}":
2116
2129
2117
2130
1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to "{{AudioContextState/suspended}}".
@@ -12121,70 +12134,69 @@ to halt audio playback for an {{AudioContext}}. For example, The user agent may
12121
12134
create an interruption when another application requests exclusive access to the
12122
12135
audio output hardware.
12123
12136
12124
- When an [=interruption=] happens, the user agent must <a>queue a control message</a>
12137
+ When an [=interruption=] happens, the user agent MUST <a>queue a control message</a>
12125
12138
to interrupt the {{AudioContext}}.
12126
12139
12127
12140
Running a <a>control message</a> to <dfn attribute for="AudioContext"
12128
12141
lt="interruption-start">interrupt an {{AudioContext}}</dfn> |context|
12129
12142
means running these steps on the <a>rendering thread</a>:
12130
12143
12131
- 1. If the |context|'s {{[[rendering thread state]]}} is <code>closed</code>
12132
- or <code>interrupted</code>:
12133
-
12134
- 1. Abort these steps.
12144
+ 1. If the |context|'s {{[[rendering thread state]]}} is
12145
+ {{AudioContextState/closed}} or {{AudioContextState/interrupted}}, abort
12146
+ these steps.
12135
12147
12136
12148
1. If the |context|'s {{[[rendering thread state]]}} is
12137
- <code>running</code> :
12149
+ {{AudioContextState/running}} :
12138
12150
12139
12151
1. Attempt to <a>release system resources</a>.
12140
12152
12141
12153
1. [=Queue a media element task=] to execute the following steps:
12142
12154
12143
12155
1. Set the |context|'s {{[[control thread state]]}} to
12144
- <code>interrupted</code>.
12156
+ {{AudioContextState/interrupted}}.
12157
+
12158
+ 1. Set the |context|'s {{[[interrupt end return state]]}} slot to
12159
+ "{{AudioContextState/running}}".
12145
12160
12146
12161
1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
12147
12162
|context|.
12148
12163
12149
12164
1. If the |context|'s {{[[rendering thread state]]}} is
12150
- <code>suspended</code> :
12165
+ {{AudioContextState/suspended}} :
12151
12166
12152
12167
1. [=Queue a media element task=] to execute the following steps:
12153
12168
12154
12169
1. Set the |context|'s {{[[control thread state]]}} to
12155
- <code>interrupted</code>.
12170
+ {{AudioContextState/interrupted}}.
12171
+
12172
+ 1. Set the |context|'s {{[[interrupt end return state]]}} slot to
12173
+ "{{AudioContextState/suspended}}".
12156
12174
12157
12175
1. Set the |context|'s {{[[rendering thread state]]}} to
12158
- <code>interrupted</code> .
12176
+ {{AudioContextState/interrupted}} .
12159
12177
12160
- Note: If the {{AudioContext}} is <code>suspended</code> a
12178
+ Note: If the {{AudioContext}} is {{AudioContextState/suspended}} a
12161
12179
{{BaseAudioContext/statechange}} event is not fired for privacy reasons to avoid
12162
12180
over-sharing user activity - e.g. when a phone call comes in or when the screen
12163
12181
gets locked.
12164
12182
12165
- When an [=interruption=] ends, the user agent must <a>queue a control message</a>
12183
+ When an [=interruption=] ends, the user agent MUST <a>queue a control message</a>
12166
12184
to <dfn attribute for="AudioContext" lt="interruption-end">end the
12167
12185
{{AudioContext}} interruption</dfn>.
12168
12186
12169
- <dfn lt="linear PCM">Linear pulse code modulation</dfn>
12170
-
12171
12187
Running a <a>control message</a> to end an {{AudioContext}} |context|
12172
12188
[=interruption=] means running these steps on the <a>rendering thread</a>:
12173
12189
12174
12190
1. If the |context|'s {{[[rendering thread state]]}} is not
12175
- <code>interrupted</code>:
12191
+ {{AudioContextState/interrupted}}, abort these steps.
12176
12192
12177
- 1. Abort these steps.
12178
-
12179
- 1. If the |context|'s {{[[rendering thread state]]}} was
12180
- <code>running</code> before the [=interruption=] or if the the
12181
- |context|'s {{[[rendering thread state]]}} was <code>suspended</code>
12182
- and {{AudioContext/resume}} was called during the [=interruption=]:
12193
+ 1. If the |context|'s {{[[interrupt end return state]]}} is
12194
+ "{{AudioContextState/running}}":
12183
12195
12184
12196
1. Attempt to <a href="#acquiring">acquire system resources</a>.
12185
12197
12186
12198
1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
12187
- <code>running</code> .
12199
+ "{{AudioContextState/running}}" .
12188
12200
12189
12201
1. Start <a href="#rendering-loop">rendering the audio graph</a>.
12190
12202
@@ -12194,13 +12206,13 @@ Running a <a>control message</a> to end an {{AudioContext}} |context|
12194
12206
is not already "{{AudioContextState/running}}":
12195
12207
12196
12208
1. Set the |context|'s {{[[control thread state]]}} to
12197
- <code>running</code> .
12209
+ "{{AudioContextState/running}}" .
12198
12210
12199
12211
1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
12200
12212
|context|.
12201
12213
12202
- 1. If the |context|'s {{[[rendering thread state]]}} was
12203
- <code>suspended</code> before the [=interruption=]:
12214
+ 1. If the |context|'s {{[[interrupt end return state]]}} is
12215
+ "{{AudioContextState/suspended}}"
12204
12216
12205
12217
1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
12206
12218
<code>suspended</code>.
@@ -12210,6 +12222,8 @@ Running a <a>control message</a> to end an {{AudioContext}} |context|
12210
12222
1. Set the |context|'s {{[[control thread state]]}} to
12211
12223
<code>suspended</code>.
12212
12224
12225
+ 1. Set the |context|'s {{[[interrupt end return state]]}} to `null`.
12226
+
12213
12227
<h3 id="error-handling-on-a-running-audio-context">
12214
12228
Handling an error from System Audio Resources on the {{AudioContext}}</h3>
12215
12229
0 commit comments