Commit Graph

76 Commits

Author SHA1 Message Date
Ehsan Akhgari
c6f415d397 Bug 1180347 - Split media.useAudioChannelService to support turning the service on without turning the Firefox OS specific APIs on; r=baku
This is going to be needed for us to be able to turn the AudioChannelService
on for desktop without exposing the Firefox OS specific APIs.
2015-07-06 09:05:00 -04:00
Paul Adenot
e32b404e54 Bug 1094764 - Implement AudioContext.suspend and friends. r=roc,ehsan
- Relevant spec text:
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-suspend-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-resume-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-close-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-state
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-onstatechange

- In a couple words, the behavior we want:
    - Closed context cannot have new nodes created, but can do decodeAudioData,
    and create buffers, and such.
    - OfflineAudioContexts don't support those methods, transitions happen at
    startRendering and at the end of processing. onstatechange is used to make
    this observable.
    - (regular) AudioContexts support those methods. The promises and
    onstatechange should be resolved/called when the operation has actually
    completed on the rendering thread.  Once a context has been closed, it
    cannot transition back to "running". An AudioContext switches to "running"
    when the audio callback start running, this allow authors to know how long
    the audio stack takes to start running.
    - MediaStreams that feed in/go out of a suspended graph should respectively
    not buffer at the graph input, and output silence
    - suspended context should not be doing much on the CPU, and we should try
    to pause audio streams if we can (this behaviour is the main reason we need
    this in the first place, for saving battery on mobile, and CPU on all
    platforms)

- Now, the implementation:
    - AudioNodeStreams are now tagged with a context id, to be able to operate
    on all the streams of a given AudioContext on the Graph thread without
    having to go and lock everytime to touch the AudioContext. This happens in
    the AudioNodeStream ctor. IDs are of course constant for the lifetime of the
    node.
    - When an AudioContext goes into suspended mode, streams for this
    AudioContext are moved out of the mStreams array to a second array,
    mSuspendedStreams. Streams in mSuspendedStream are not ordered, and are not
    processed.
    - The MSG will automatically switch to a SystemClockDriver when it finds
    that there are no more AudioNodeStream/Stream with an audio track. This is
    how pausing the audio subsystem and saving battery works. Subsequently, when
    the MSG finds that there are only streams in mSuspendedStreams, it will go
    to sleep (block on a monitor), so we save CPU, but it does not shut itself
    down. This is mostly not a new behaviour (this is what the MSG does since
    the refactoring), but is important to note.
    - Promises are gripped (addref-ed) on the main thread, and then shepherd
    down other threads and to the GraphDriver, if needed (sometimes we can
    resolve them right away). They move between threads as void* to prevent
    calling methods on them, as they are not thread safe. Then, the driver
    executes the operation, and when it's done (initializing and closing audio
    streams can take some time), we send the promise back to the main thread,
    and resolve it, casting back to Promise* after asserting we're back on the
    main thread. This way, we can send them back on the main thread once an
    operation has complete (suspending an audio stream, starting it again on
    resume(), etc.), without having to do bookkeeping between suspend calls and
    their result. Promises are not thread safe, so we can't move them around
    AddRef-ed.
    - The stream destruction logic now takes into account that a stream can be
    destroyed while not being in mStreams.
    - A graph can now switch GraphDriver twice or more per iteration, for
    example if an author goes suspend()/resume()/suspend() in the same script.
    - Some operation have to be done on suspended stream, so we now use double
    for-loop around mSuspendedStreams and mStreams in some places in
    MediaStreamGraph.cpp.
    - A tricky part was making sure everything worked at AudioContext
    boundaries.  TrackUnionStream that have one of their input stream suspended
    append null ticks instead.
    - The graph ordering algorithm had to be altered to not include suspended
    streams.
    - There are some edge cases (adding a stream on a suspended graph, calling
    suspend/resume when a graph has just been close()d).
2015-02-27 18:22:05 +01:00
Carsten "Tomcat" Book
31c4421faf Backed out changeset 7fc52c48e6e3 (bug 1094764) for mulet m-3 perma failure in /test_dataChannel_basicAudioVideo.html 2015-04-09 13:44:27 +02:00
Paul Adenot
70b6a9e143 Bug 1094764 - Implement AudioContext.suspend and friends. r=roc,ehsan
- Relevant spec text:
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-suspend-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-resume-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-close-Promise
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-state
    - http://webaudio.github.io/web-audio-api/#widl-AudioContext-onstatechange

- In a couple words, the behavior we want:
    - Closed context cannot have new nodes created, but can do decodeAudioData,
    and create buffers, and such.
    - OfflineAudioContexts don't support those methods, transitions happen at
    startRendering and at the end of processing. onstatechange is used to make
    this observable.
    - (regular) AudioContexts support those methods. The promises and
    onstatechange should be resolved/called when the operation has actually
    completed on the rendering thread.  Once a context has been closed, it
    cannot transition back to "running". An AudioContext switches to "running"
    when the audio callback start running, this allow authors to know how long
    the audio stack takes to start running.
    - MediaStreams that feed in/go out of a suspended graph should respectively
    not buffer at the graph input, and output silence
    - suspended context should not be doing much on the CPU, and we should try
    to pause audio streams if we can (this behaviour is the main reason we need
    this in the first place, for saving battery on mobile, and CPU on all
    platforms)

- Now, the implementation:
    - AudioNodeStreams are now tagged with a context id, to be able to operate
    on all the streams of a given AudioContext on the Graph thread without
    having to go and lock everytime to touch the AudioContext. This happens in
    the AudioNodeStream ctor. IDs are of course constant for the lifetime of the
    node.
    - When an AudioContext goes into suspended mode, streams for this
    AudioContext are moved out of the mStreams array to a second array,
    mSuspendedStreams. Streams in mSuspendedStream are not ordered, and are not
    processed.
    - The MSG will automatically switch to a SystemClockDriver when it finds
    that there are no more AudioNodeStream/Stream with an audio track. This is
    how pausing the audio subsystem and saving battery works. Subsequently, when
    the MSG finds that there are only streams in mSuspendedStreams, it will go
    to sleep (block on a monitor), so we save CPU, but it does not shut itself
    down. This is mostly not a new behaviour (this is what the MSG does since
    the refactoring), but is important to note.
    - Promises are gripped (addref-ed) on the main thread, and then shepherd
    down other threads and to the GraphDriver, if needed (sometimes we can
    resolve them right away). They move between threads as void* to prevent
    calling methods on them, as they are not thread safe. Then, the driver
    executes the operation, and when it's done (initializing and closing audio
    streams can take some time), we send the promise back to the main thread,
    and resolve it, casting back to Promise* after asserting we're back on the
    main thread. This way, we can send them back on the main thread once an
    operation has complete (suspending an audio stream, starting it again on
    resume(), etc.), without having to do bookkeeping between suspend calls and
    their result. Promises are not thread safe, so we can't move them around
    AddRef-ed.
    - The stream destruction logic now takes into account that a stream can be
    destroyed while not being in mStreams.
    - A graph can now switch GraphDriver twice or more per iteration, for
    example if an author goes suspend()/resume()/suspend() in the same script.
    - Some operation have to be done on suspended stream, so we now use double
    for-loop around mSuspendedStreams and mStreams in some places in
    MediaStreamGraph.cpp.
    - A tricky part was making sure everything worked at AudioContext
    boundaries.  TrackUnionStream that have one of their input stream suspended
    append null ticks instead.
    - The graph ordering algorithm had to be altered to not include suspended
    streams.
    - There are some edge cases (adding a stream on a suspended graph, calling
    suspend/resume when a graph has just been close()d).
2015-02-27 18:22:05 +01:00
Paul Adenot
64983bc928 Bug 1113925 - Don't return null in AudioContext.decodeAudioData. r=bz
--HG--
extra : rebase_source : c3efee1ad98547003d7ea16e068c0bacf2ea9e46
2015-01-05 13:43:00 +01:00
Roshan Vidyashankar
3fc5328ed1 Bug 1057585 - Disable WebAudio APIs in prerendering; r=jst 2014-12-21 11:53:32 -05:00
Paul Adenot
538c6b59c6 Bug 1100349 - Implement StereoPannerNode. r=ehsan,smaug
--HG--
extra : rebase_source : c0d3df3c4ea01001c0800997edbdf441c7287fb8
2014-11-19 18:15:13 +01:00
Andrea Marchesini
e466bd1f2e Bug 1073615 - One MediaStreamGraph singleton per audioChannel, r=roc 2014-11-17 16:07:55 +00:00
Paul Adenot
6d1f890a82 Bug 1000264 - Make AudioContext.decodeAudioData return a promise. r=ehsan,bz
--HG--
extra : rebase_source : 570014ee470ca5493073113ab3bc4bb0933c390a
2014-10-23 12:07:48 +02:00
Ryan VanderMeulen
064303be00 Backed out changesets 0c9407b0e481, c2c37b2e9fac, and 488700194519 (bug 1000264) for e10s test failures.
CLOSED TREE
2014-11-13 12:40:15 -05:00
Paul Adenot
9b0650a20e Bug 1000264 - Make AudioContext.decodeAudioData return a promise. r=ehsan,bz
--HG--
extra : rebase_source : 79e8b89ddc5d08ccdd131f9b827c9110da0238ee
2014-10-23 12:07:48 +02:00
Ryan VanderMeulen
1b0c318bb9 Backed out changeset 5a476e673470 (bug 1073615) for causing various intermittent failures. 2014-11-12 11:52:30 -05:00
Andrea Marchesini
87c2435185 Bug 1073615 - One MediaStreamGraph singleton per audioChannel. r=roc 2014-09-29 03:43:00 -04:00
Ryan VanderMeulen
dbb11fdd67 Backed out changeset 11f95edf23a4 (bug 1073615) for frequent mochitest-bc timeouts. 2014-10-01 13:04:02 -04:00
Andrea Marchesini
3a8f6e7a5f Bug 1073615 - One MediaStreamGraph singleton per audioChannel, r=roc 2014-09-30 18:35:32 +01:00
Andrea Marchesini
fac69fce74 Bug 1046582 - mochitest for AudioChannel changes in MediaStream objects, r=ehsan, r=bz 2014-08-03 14:46:17 +01:00
Andrea Marchesini
8597ce0a97 Bug 1023175 - AudioContext should have attribute EventHandler onmozinterruptend/begin in the webIDL interface, r=ehsan, r=smaug 2014-06-13 07:06:14 +01:00
Star Cheng
055bd5f25b Bug 984498: add new a parameter(audiochannel type) to AudioContext API. r=roc 2014-04-18 14:06:23 +08:00
Ehsan Akhgari
6eeb144cc5 Bug 999908 - Remove support for the Web Audio legacy prefs for AudioBufferSourceNode, AudioContext, and AudioParam; r=padenot 2014-04-23 08:56:42 -04:00
Ehsan Akhgari
95cbd5d2b1 Bug 968479 - Remove the media.webaudio.enabled pref; r=roc
--HG--
extra : rebase_source : 3618cb3097aa99a79a06af016bf6b3a3c6f77208
2014-02-06 08:36:46 -05:00
Andrea Marchesini
8e89b14fa1 Bug 925594 - WebIDL enum for AudioChannel in HTMLMediaElement, r=ehsan, r=khuey 2013-10-28 17:08:14 -07:00
Carsten "Tomcat" Book
d00bdf2431 Backed out changeset 5506e7033c85 (bug 925594) perma-orange mochitest test-failure on b2g-ics
--HG--
extra : transplant_source : %19E%9F_%BF%84%27%11%0D%DE%CA.%E7%09%9D%FD3%1A2U
2013-10-28 15:34:08 +01:00
Andrea Marchesini
028b3d33fb Bug 925594 - WebIDL enum for AudioChannel in HTMLMediaElement, r=ehsan, r=khuey 2013-10-28 03:45:10 -07:00
Peter Van der Beken
70d1256549 Bug 922159 - Rename Creator WebIDL extended attribute to NewObject. r=bz.
--HG--
extra : rebase_source : 80791f28acbf8e2cc21946b0d62bb8555b53fc99
2013-09-30 18:32:22 +02:00
Ed Morley
ef2d7c5fe8 Backed out changeset 64a19bc0e198 (bug 922159) for compilation failures on a CLOSED TREE 2013-10-23 15:51:48 +01:00
Peter Van der Beken
538eed5d23 Bug 922159 - Rename Creator WebIDL extended attribute to NewObject. r=bz.
--HG--
extra : rebase_source : 2c09c54f42a111d27b0d57346ca7d80f440eca09
2013-09-30 18:32:22 +02:00
Andrea Marchesini
e103c1c47e Bug 924870 - AudioContext.mozAudioChannel attribute, r=ehsan 2013-10-11 13:55:47 +02:00
Ehsan Akhgari
3eb725fd41 Bug 865253 - Part 1: Implement the DOM bindings for OscillatorNode; r=roc 2013-08-19 11:53:00 -07:00
Ehsan Akhgari
0151f23455 Bug 855568 - Implement MediaElementAudioSourceNode
X-Git-Commit-ID: 52f1fcdd561e8214e6820a3f2478d9e8b9623430

--HG--
extra : rebase_source : c40cd0c7070dec9e0273093499228f13906f8fc5
2013-07-25 15:01:49 +12:00
secretrobotron
84e2becf3b Bug 856361. Part 5: Implement MediaStreamAudioSourceNode. r=ehsan
--HG--
extra : rebase_source : 265f31edda31a2f749eacc568919304622446748
2013-07-24 23:29:39 +12:00
Paul Adenot
0b0d2ff170 Bug 883591 - Don't allow creating a MediaStreamDestinationNode on an OfflineAudioContext. r=ehsan 2013-07-18 11:57:38 +02:00
Ehsan Akhgari
508e8b2f4d Bug 889016 - Part 2: Report an error in the synchronous AudioContext.createBuffer unless the legacy pref has been set; r=roc 2013-07-04 09:25:12 -04:00
Ehsan Akhgari
cbdefabbd2 Bug 886165 - Hide the alternate names in the spec behind prefs which are turned off by default; r=roc
This patch uses one pref per interface, to allow us finer grain control over
which ones we might need to turn on in the future.
2013-06-23 19:22:10 -04:00
Ehsan Akhgari
acfc21a9c4 Bug 865256 - Part 2: Rename WaveTable to PeriodicWave; r=roc
--HG--
rename : content/media/webaudio/WaveTable.cpp => content/media/webaudio/PeriodicWave.cpp
rename : content/media/webaudio/WaveTable.h => content/media/webaudio/PeriodicWave.h
rename : content/media/webaudio/test/test_waveTable.html => content/media/webaudio/test/test_periodicWave.html
rename : dom/webidl/WaveTable.webidl => dom/webidl/PeriodicWave.webidl
2013-06-19 18:24:26 -04:00
Josh Matthews
5cb0162f45 Bug 865257 - Implement MediaStreamAudioDestinationNode. r=ehsan,roc 2013-05-21 15:17:47 -04:00
Ehsan Akhgari
e71db503bf Bug 815643 - Part 1: Implement the DOM bindings for ConvolverNode; r=roc
--HG--
extra : rebase_source : 9f6853dcaeeac1f36aa8c2ee90991a7f0ea0b145
2013-06-10 16:07:55 -04:00
Ehsan Akhgari
615f1f5b8a Bug 865256 - Part 1: Implement the DOM bindings for WaveTable; r=roc 2013-05-28 07:19:07 -04:00
Ehsan Akhgari
5cba21896b Bug 865251 - Implement WaveShaperNode; r=roc 2013-05-14 00:12:30 -04:00
Ehsan Akhgari
e7db49b259 Bug 865248 - Implement ChannelMergerNode; r=roc
--HG--
rename : content/media/webaudio/ChannelSplitterNode.h => content/media/webaudio/ChannelMergerNode.h
2013-05-05 11:49:37 -04:00
Ehsan Akhgari
a376fef6c5 Bug 865247 - Part 4: Implement ChannelSplitterNode; r=roc 2013-05-05 11:49:13 -04:00
James Willcox
0cf4dbdef2 Bug 848652 - Implement ArrayBuffer version of AudioContext.createBuffer r=ehsan
--HG--
rename : content/media/webaudio/test/test_decodeAudioData.html => content/media/webaudio/test/test_mediaDecoding.html
2013-05-03 16:42:28 -04:00
Matt Brubeck
4ac559870b Back out changeset 1a0f522cf110 (bug 848652) because of assertion failures in MediaBufferDecoder.cpp
CLOSED TREE

--HG--
rename : content/media/webaudio/test/test_mediaDecoding.html => content/media/webaudio/test/test_decodeAudioData.html
2013-05-03 15:18:06 -07:00
James Willcox
fd7dbdb682 # ebe5edd8c0ac367c043437a674d4200cf4525757
Bug 848652 - Implement ArrayBuffer version of AudioContext.createBuffer r=ehsan

--HG--
rename : content/media/webaudio/test/test_decodeAudioData.html => content/media/webaudio/test/test_mediaDecoding.html
extra : rebase_source : 7b0926091743dd6cd17a0adee9a6d3c5181dfa4d
2013-05-03 16:42:28 -04:00
Ehsan Akhgari
eabaf3e71e Bug 859600 - Make AudioContext an EventTarget; r=smaug 2013-04-25 00:28:39 -04:00
Ehsan Akhgari
21b6d807c6 Bug 834513 - Part 3: Implement ScriptProcessorNode; r=roc 2013-04-13 21:37:04 -04:00
Ehsan Akhgari
c2ff4fe5ac Bug 859595 - Implement the alternate names for AudioBufferSourceNode, AudioContext and AudioParam; r=bzbarsky
Let this be mentioned in our code base history that I wrote this patch
with tears in my eyes.  This is the saddest thing I've ever had to do to
Gecko. :(

--HG--
extra : rebase_source : 798e5b1dc8af51a399189dd05bc59ac077670820
2013-04-11 22:08:05 -04:00
Ehsan Akhgari
041579978f Bug 855990 - Part 1: Implement the DOM bindings to AnalyserNode; r=bzbarsky 2013-03-31 23:41:14 -04:00
Ehsan Akhgari
47f0c99c37 Backed out changeset 81bad314826a (bug 855990) because of build bustage 2013-04-01 18:41:30 -04:00
Ehsan Akhgari
9930599736 Bug 855990 - Part 1: Implement the DOM bindings to AnalyserNode; r=bzbarsky 2013-03-31 23:41:14 -04:00
Ehsan Akhgari
659ae889aa Bug 851338 - Implement AudioContext.currentTime; r=roc 2013-03-14 21:01:02 -04:00