diff --git a/index.bs b/index.bs index 4375c7e6b..a3a10af15 100644 --- a/index.bs +++ b/index.bs @@ -717,7 +717,8 @@ for="BaseAudioContext">[[control thread state]] that take values from enum AudioContextState { "suspended", "running", - "closed" + "closed", + "interrupted" }; @@ -745,6 +746,12 @@ enum AudioContextState {
closed
reject the
promise with {{InvalidStateError}}, abort these steps,
returning promise.
- 3. Set {{[[suspended by user]]}} to false
.
+ 1. Set {{[[suspended by user]]}} to false
.
- 4. If the context is not allowed to start, append
- promise to {{BaseAudioContext/[[pending promises]]}} and
- {{AudioContext/[[pending resume promises]]}} and abort these steps, returning
- promise.
+ 1. If the {{[[control thread state]]}} on the {{AudioContext}} is
+ suspended
and there is an ongoing
+ [=interruption=]:
- 5. Set the {{[[control thread state]]}} on the
- {{AudioContext}} to running
.
+ 1. Queue a media element task to execute the following steps:
- 6. Queue a control message to resume the {{AudioContext}}.
+ 1. Set the {{BaseAudioContext/state}} attribute of the
+ {{AudioContext}} to "{{AudioContextState/interrupted}}".
- 7. Return promise.
+ 1. [=Queue a media element task=] to [=fire an event=] named
+ {{BaseAudioContext/statechange}} at the {{AudioContext}}.
+
+ 1. Reject the promise with {{InvalidStateError}}, abort these
+ steps, returning promise.
+
+ 1. If the context is not allowed to start, append
+ promise to {{BaseAudioContext/[[pending promises]]}}
+ and {{AudioContext/[[pending resume promises]]}} and abort
+ these steps, returning promise.
+
+ 1. Set the {{[[control thread state]]}} on the {{AudioContext}} to
+ running
.
+
+ 1. Queue a control message to resume the {{AudioContext}}.
+
+ 1. Return promise.
closed
+ or interrupted
:
+
+ 1. Abort these steps.
+
+1. If the |context|'s {{[[rendering thread state]]}} is
+ running
:
+
+ 1. Attempt to release system resources.
+
+ 1. [=Queue a media element task=] to execute the following steps:
+
+ 1. Set the |context|'s {{[[control thread state]]}} to
+ interrupted
.
+
+ 1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
+ |context|.
+
+1. If the |context|'s {{[[rendering thread state]]}} is
+ suspended
:
+
+ 1. [=Queue a media element task=] to execute the following steps:
+
+ 1. Set the |context|'s {{[[control thread state]]}} to
+ interrupted
.
+
+1. Set the |context|'s {{[[rendering thread state]]}} to
+ interrupted
.
+
+Note: If the {{AudioContext}} is suspended
a
+{{BaseAudioContext/statechange}} event is not fired for privacy reasons to avoid
+over-sharing user activity - e.g. when a phone call comes in or when the screen
+gets locked.
+
+When an [=interruption=] ends, the user agent must queue a control message
+to end the
+{{AudioContext}} interruption.
+
+Linear pulse code modulation
+
+Running a control message to end an {{AudioContext}} |context|
+[=interruption=] means running these steps on the rendering thread:
+
+1. If the |context|'s {{[[rendering thread state]]}} is not
+ interrupted
:
+
+ 1. Abort these steps.
+
+1. If the |context|'s {{[[rendering thread state]]}} was
+ running
before the [=interruption=] or if the the
+ |context|'s {{[[rendering thread state]]}} was suspended
+ and {{AudioContext/resume}} was called during the [=interruption=]:
+
+ 1. Attempt to acquire system resources.
+
+ 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
+ running
.
+
+ 1. Start rendering the audio graph.
+
+ 1. [=Queue a media element task=] to execute the following steps:
+
+ 1. If the {{BaseAudioContext/state}} attribute of the {{AudioContext}}
+ is not already "{{AudioContextState/running}}":
+
+ 1. Set the |context|'s {{[[control thread state]]}} to
+ running
.
+
+ 1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the
+ |context|.
+
+1. If the |context|'s {{[[rendering thread state]]}} was
+ suspended
before the [=interruption=]:
+
+ 1. Set the {{[[rendering thread state]]}} on the {{AudioContext}} to
+ suspended
.
+
+ 1. [=Queue a media element task=] to execute the following steps:
+
+ 1. Set the |context|'s {{[[control thread state]]}} to
+ suspended
.
+