Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Issue 625363004: Implement suspend/resume for AudioContext (Closed)

Created:
6 years, 2 months ago by Raymond Toy
Modified:
6 years, 1 month ago
Reviewers:
haraken, tkent, yhirano
CC:
blink-reviews
Project:
blink
Visibility:
Public.

Description

Implement suspend/resume for AudioContext WebAudio is adding a suspend()/resume() API: https://github.com/WebAudio/web-audio-api/issues/361 https://github.com/WebAudio/web-audio-api/issues/317 In more detail, here is the proposed additions to the spec: New attribute "state" with values: paused Currently paused (time is not proceeding, audio hardware may be powered down/released). running Audio is being processed. released AudioContext has been released, and can no longer be used to process audio. All system resources should be released. void suspend() Suspends the progression of time in the audio context, allows any current buffer contents to be played to the destination and then allows the system to power down and/or release audio hardware. If the context has been released, an InvalidStateError MUST be thrown. This is generally useful when the application knows it will not need the AudioContext for some time, and wishes to let the audio hardware power down. While the system is suspend, MediaStreams will have their output ignored; that is, data will be lost by the real time nature of media streams. HTMLMediaElements will similarly have their output ignored until the system is resumed. Audio Workers and ScriptProcessorNodes will simply not fire their onaudioprocess events while suspended, but will resume when resumed. For the purpose of AnalyserNode window functions, the data is considered as a continuous stream - i.e. the resume()/suspend() does not cause silence to appear in the AnalyserNode's stream of data. Promise resume() Resumes the progression of time in the audio context, which may involve re-priming the frame buffer contents. The promise resolves when the system has re-acquired (if necessary) access to audio hardware and has begun streaming to the destination, or immediately (with no other effect) if the context is already running. The promise is rejected if the context has been released. BUG=420106 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=183916

Patch Set 1 #

Patch Set 2 : Handle OfflineAudioContexts #

Patch Set 3 : #

Total comments: 6

Patch Set 4 : Rebase (only) #

Patch Set 5 : Update according to spec #

Patch Set 6 : Fix typos in comments. #

Patch Set 7 : #

Patch Set 8 : Fix typo caught by bots but not locally #

Total comments: 29

Patch Set 9 : Address review comments #

Patch Set 10 : Address more review comments #

Patch Set 11 : Rename setState to setContextState #

Patch Set 12 : Fix build error. #

Total comments: 6

Patch Set 13 : Address review comments. #

Patch Set 14 : Update according to new webaudio spec #

Unified diffs Side-by-side diffs Delta from patch set Stats (+386 lines, -3 lines) Patch
A LayoutTests/webaudio/audiocontext-suspend-resume.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +110 lines, -0 lines 0 comments Download
A LayoutTests/webaudio/audiocontext-suspend-resume-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +20 lines, -0 lines 0 comments Download
M Source/modules/webaudio/AudioContext.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 6 chunks +41 lines, -0 lines 0 comments Download
M Source/modules/webaudio/AudioContext.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 11 chunks +182 lines, -2 lines 0 comments Download
M Source/modules/webaudio/AudioContext.idl View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +13 lines, -0 lines 0 comments Download
M Source/modules/webaudio/AudioDestinationNode.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M Source/modules/webaudio/DefaultAudioDestinationNode.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M Source/modules/webaudio/DefaultAudioDestinationNode.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +12 lines, -1 line 0 comments Download
M Source/modules/webaudio/OfflineAudioDestinationNode.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M Source/modules/webaudio/OfflineAudioDestinationNode.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 29 (6 generated)
Raymond Toy
PTAL
6 years, 2 months ago (2014-10-07 17:09:42 UTC) #2
haraken
hirano-san: Would you take a look at the Promise part of this change?
6 years, 2 months ago (2014-10-08 00:31:37 UTC) #4
yhirano
https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp#newcode846 Source/modules/webaudio/AudioContext.cpp:846: ASSERT(isMainThread); Please acquire the lock. https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp#newcode858 Source/modules/webaudio/AudioContext.cpp:858: Please add ...
6 years, 2 months ago (2014-10-08 01:12:14 UTC) #5
yhirano
https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp#newcode846 Source/modules/webaudio/AudioContext.cpp:846: ASSERT(isMainThread); On 2014/10/08 01:12:14, yhirano wrote: > Please acquire ...
6 years, 2 months ago (2014-10-08 01:15:54 UTC) #6
Raymond Toy
On 2014/10/08 at 01:15:54, yhirano wrote: > https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp > File Source/modules/webaudio/AudioContext.cpp (right): > > https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp#newcode846 ...
6 years, 2 months ago (2014-10-09 17:50:38 UTC) #7
yhirano
On 2014/10/09 17:50:38, Raymond Toy wrote: > On 2014/10/08 at 01:15:54, yhirano wrote: > > ...
6 years, 2 months ago (2014-10-14 04:40:50 UTC) #8
Raymond Toy
https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/40001/Source/modules/webaudio/AudioContext.cpp#newcode846 Source/modules/webaudio/AudioContext.cpp:846: ASSERT(isMainThread); On 2014/10/08 01:12:14, yhirano wrote: > Please acquire ...
6 years, 2 months ago (2014-10-14 17:16:59 UTC) #9
Raymond Toy
yhirano: PTAL and the locking and ScriptPromise items again. haraken: PTAL at the overall CL. ...
6 years, 2 months ago (2014-10-14 17:19:20 UTC) #10
yhirano
lgtm https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp#newcode898 Source/modules/webaudio/AudioContext.cpp:898: m_resumePromises[k]->reject(); [opt] In general, it would be better ...
6 years, 2 months ago (2014-10-15 09:02:27 UTC) #11
haraken
The approach looks good. https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp#newcode173 Source/modules/webaudio/AudioContext.cpp:173: m_destinationNode->startRendering(); You can call startRendering() ...
6 years, 2 months ago (2014-10-15 15:36:26 UTC) #12
Raymond Toy
https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/170001/Source/modules/webaudio/AudioContext.cpp#newcode565 Source/modules/webaudio/AudioContext.cpp:565: break; On 2014/10/15 15:36:26, haraken wrote: > > Shall ...
6 years, 2 months ago (2014-10-15 16:31:56 UTC) #13
Raymond Toy
PTAL. I think I've addressed all of your comments. I've also added some comments on ...
6 years, 2 months ago (2014-10-15 19:50:50 UTC) #14
haraken
LGTM This needs API owner review. https://codereview.chromium.org/625363004/diff/220011/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/220011/Source/modules/webaudio/AudioContext.cpp#newcode143 Source/modules/webaudio/AudioContext.cpp:143: AudioContext::~AudioContext() Can we ...
6 years, 2 months ago (2014-10-16 01:13:44 UTC) #15
Raymond Toy
https://codereview.chromium.org/625363004/diff/220011/Source/modules/webaudio/AudioContext.cpp File Source/modules/webaudio/AudioContext.cpp (right): https://codereview.chromium.org/625363004/diff/220011/Source/modules/webaudio/AudioContext.cpp#newcode143 Source/modules/webaudio/AudioContext.cpp:143: AudioContext::~AudioContext() On 2014/10/16 01:13:43, haraken wrote: > > Can ...
6 years, 2 months ago (2014-10-16 17:56:31 UTC) #16
Raymond Toy
tkent@: can you review this as an API owner?
6 years, 2 months ago (2014-10-16 17:59:45 UTC) #18
tkent
lgtm. I don't think we need "Intent to ship" for this feature. However, I recommend ...
6 years, 2 months ago (2014-10-17 00:37:18 UTC) #19
Raymond Toy
On 2014/10/17 at 00:37:18, tkent wrote: > lgtm. > > I don't think we need ...
6 years, 2 months ago (2014-10-17 15:45:29 UTC) #20
Raymond Toy
Thanks, everyone, for your reviews!
6 years, 2 months ago (2014-10-17 15:45:59 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/625363004/260001
6 years, 2 months ago (2014-10-17 15:47:18 UTC) #23
commit-bot: I haz the power
Try jobs failed on following builders: win_blink_rel on tryserver.blink (http://build.chromium.org/p/tryserver.blink/builders/win_blink_rel/builds/32332)
6 years, 2 months ago (2014-10-17 17:56:18 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/625363004/260001
6 years, 2 months ago (2014-10-17 18:02:24 UTC) #27
commit-bot: I haz the power
Committed patchset #13 (id:260001) as 183916
6 years, 2 months ago (2014-10-17 19:25:04 UTC) #28
dstockwell
6 years, 2 months ago (2014-10-19 23:34:14 UTC) #29
Message was sent while issue was closed.
A revert of this CL (patchset #13 id:260001) has been created in
https://codereview.chromium.org/663003002/ by dstockwell@chromium.org.

The reason for reverting is: Breaks webaudio/oscillator-sine.html on Windows.

Powered by Google App Engine
This is Rietveld 408576698