Skip to content

Commit b4798cc

Browse files
gabrielsanbritohoch
authored andcommitted
improve algorithms
1 parent e40539f commit b4798cc

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

index.bs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ enum AudioContextState {
752752
"<dfn>interrupted</dfn>"
753753
<td>
754754
This context is currently interrupted and cannot process audio
755-
until the interruption ends.
755+
until the [=interruption=] ends.
756756
</table>
757757
</div>
758758

@@ -1972,37 +1972,36 @@ Methods</h4>
19721972
2. Let <var>promise</var> be a new Promise.
19731973

19741974
3. If the {{[[control thread state]]}} on the
1975-
{{AudioContext}} is <code>closed</code> or <code>interrupted</code> reject the
1975+
{{AudioContext}} is <code>closed</code> reject the
19761976
promise with {{InvalidStateError}}, abort these steps,
19771977
returning <var>promise</var>.
19781978

19791979
4. Set {{[[suspended by user]]}} to <code>false</code>.
19801980

1981-
4. If the {{BaseAudioContext/state}} attribute of the {{AudioContext}} is "{{AudioContextState/suspended}}" and the {{[[control thread state]]}} on the
1982-
{{AudioContext}} is <code>interrupted</code>:
1981+
5. If the {{[[control thread state]]}} on the
1982+
{{AudioContext}} is <code>suspended</code> and there is an ongoing [=interruption=]:
1983+
1984+
1. Queue a media element task</a> to execute the following steps:
19831985

1984-
1. <a href="https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task">
1985-
queue a media element task</a> to execute the following steps:
1986-
19871986
1. Set the {{BaseAudioContext/state}} attribute of the {{AudioContext}} to "{{AudioContextState/interrupted}}".
19881987

19891988
2. [=Queue a media element task=] to [=fire an event=] named
19901989
{{BaseAudioContext/statechange}} at the {{AudioContext}}.
1991-
1990+
19921991
2. Reject the promise with {{InvalidStateError}}, abort these steps,
19931992
returning <var>promise</var>.
19941993

1995-
5. If the context is not <a>allowed to start</a>, append
1994+
6. If the context is not <a>allowed to start</a>, append
19961995
<var>promise</var> to {{BaseAudioContext/[[pending promises]]}} and
19971996
{{AudioContext/[[pending resume promises]]}} and abort these steps, returning
19981997
<var>promise</var>.
19991998

2000-
6. Set the {{[[control thread state]]}} on the
1999+
7. Set the {{[[control thread state]]}} on the
20012000
{{AudioContext}} to <code>running</code>.
20022001

2003-
7. <a>Queue a control message</a> to resume the {{AudioContext}} with <var>promise</var>.
2002+
8. <a>Queue a control message</a> to resume the {{AudioContext}} with <var>promise</var>.
20042003

2005-
8. Return <var>promise</var>.
2004+
9. Return <var>promise</var>.
20062005
</div>
20072006

20082007
<div id="context-resume" algorithm="run a control message in AudioContext">
@@ -11984,6 +11983,11 @@ buffer</a> and the value(s) of the {{AudioParam}}(s) of this
1198411983

1198511984
<h3 id="interruption-handling">Handling an interruption on the {{AudioContext}}</h3>
1198611985

11986+
An <dfn>interruption</dfn> is an event generated by the user agent when it needs to halt audio playback for
11987+
an {{AudioContext}}. For example, The user agent may create an interruption when another application
11988+
requests exclusive access to the audio output hardware. This could happen when there is an incoming
11989+
call from a VoIP application.
11990+
1198711991
The {{AudioContext}} |audioContext| performs the following steps on the <a>rendering thread</a> when an interruption happens.
1198811992

1198911993
1. If the |audioContext|'s {{[[rendering thread state]]}} is <code>closed</code> or <code>interrupted</code>:
@@ -12010,13 +12014,13 @@ The {{AudioContext}} |audioContext| performs the following steps on the <a>rende
1201012014

1201112015
Note: If the {{AudioContext}} is <code>suspended</code> 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.
1201212016

12013-
The {{AudioContext}} |audioContext| performs the following steps on the <a>rendering thread</a> when the interruption ends.
12017+
The {{AudioContext}} |audioContext| performs the following steps on the <a>rendering thread</a> when the [=interruption=] ends.
1201412018

1201512019
1. If the |audioContext|'s {{[[rendering thread state]]}} is not <code>interrupted</code>:
1201612020

1201712021
1. Abort these steps.
1201812022

12019-
1. If the |audioContext|'s {{[[rendering thread state]]}} was <code>running</code> before the interruption or if the the |audioContext|'s {{[[rendering thread state]]}} was <code>suspended</code> and {{AudioContext/resume}} was called during the interruption:
12023+
1. If the |audioContext|'s {{[[rendering thread state]]}} was <code>running</code> before the [=interruption=] or if the the |audioContext|'s {{[[rendering thread state]]}} was <code>suspended</code> and {{AudioContext/resume}} was called during the [=interruption=]:
1202012024

1202112025
1. Attempt to <a href="#acquiring">acquire system resources</a>.
1202212026

@@ -12032,7 +12036,7 @@ The {{AudioContext}} |audioContext| performs the following steps on the <a>rende
1203212036

1203312037
1. [=Fire an event=] named {{BaseAudioContext/statechange}} at the |audioContext|.
1203412038

12035-
1. If the |audioContext|'s {{[[rendering thread state]]}} was <code>suspended</code> before the interruption:
12039+
1. If the |audioContext|'s {{[[rendering thread state]]}} was <code>suspended</code> before the [=interruption=]:
1203612040

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

0 commit comments

Comments
 (0)