Skip to content

Commit

Permalink
Bug 1324352 - Implement BaseAudioContext, r=padenot
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Dec 20, 2016
1 parent f6912dd commit 59d9a61
Show file tree
Hide file tree
Showing 32 changed files with 311 additions and 311 deletions.
4 changes: 4 additions & 0 deletions dom/bindings/Bindings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ DOMInterfaces = {
'headerFile': 'mozilla/dom/BarProps.h',
},

'BaseAudioContext': {
'nativeType': 'mozilla::dom::AudioContext',
},

'Blob': {
'headerFile': 'mozilla/dom/File.h',
},
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaStreamGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "AudioNodeExternalInputStream.h"
#include "MediaStreamListener.h"
#include "MediaStreamVideoSink.h"
#include "mozilla/dom/AudioContextBinding.h"
#include "mozilla/dom/BaseAudioContextBinding.h"
#include "mozilla/media/MediaUtils.h"
#include <algorithm>
#include "GeckoProfiler.h"
Expand Down
2 changes: 2 additions & 0 deletions dom/media/webaudio/AudioContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "mozilla/dom/AnalyserNodeBinding.h"
#include "mozilla/dom/AudioBufferSourceNodeBinding.h"
#include "mozilla/dom/AudioContextBinding.h"
#include "mozilla/dom/BaseAudioContextBinding.h"
#include "mozilla/dom/BiquadFilterNodeBinding.h"
#include "mozilla/dom/ChannelMergerNodeBinding.h"
#include "mozilla/dom/ChannelSplitterNodeBinding.h"
Expand All @@ -29,6 +30,7 @@
#include "mozilla/dom/OfflineAudioContextBinding.h"
#include "mozilla/dom/OscillatorNodeBinding.h"
#include "mozilla/dom/PannerNodeBinding.h"
#include "mozilla/dom/PeriodicWaveBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/StereoPannerNodeBinding.h"
#include "mozilla/dom/WaveShaperNodeBinding.h"
Expand Down
1 change: 1 addition & 0 deletions dom/media/webaudio/MediaBufferDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MediaBufferDecoder.h"
#include "BufferDecoder.h"
#include "mozilla/dom/AudioContextBinding.h"
#include "mozilla/dom/BaseAudioContextBinding.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/ScriptSettings.h"
#include <speex/speex_resampler.h>
Expand Down
4 changes: 0 additions & 4 deletions dom/media/webaudio/test/test_OfflineAudioContext.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
}
}

expectException(function() {
ctx.createMediaStreamDestination();
}, DOMException.NOT_SUPPORTED_ERR);

expectException(function() {
new OfflineAudioContext(2, 100, 0);
}, DOMException.NOT_SUPPORTED_ERR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@
var o = new OfflineAudioContext(1, 44100, 44100);
is(o.state, "suspended", "OfflineAudioContext should start in suspended state.");

expectRejectedPromise(o, "suspend", "NotSupportedError");
expectRejectedPromise(o, "resume", "NotSupportedError");
expectRejectedPromise(o, "close", "NotSupportedError");

var previousState = o.state,
finishedRendering = false;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/AnalyserNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dictionary AnalyserOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional AnalyserOptions options)]
Constructor(BaseAudioContext context, optional AnalyserOptions options)]
interface AnalyserNode : AudioNode {

// Real-time frequency-domain data
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/AudioBuffer.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dictionary AudioBufferOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, AudioBufferOptions options)]
Constructor(BaseAudioContext context, AudioBufferOptions options)]
interface AudioBuffer {

readonly attribute float sampleRate;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/AudioBufferSourceNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dictionary AudioBufferSourceOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional AudioBufferSourceOptions options)]
Constructor(BaseAudioContext context, optional AudioBufferSourceOptions options)]
interface AudioBufferSourceNode : AudioNode {

attribute AudioBuffer? buffer;
Expand Down
81 changes: 7 additions & 74 deletions dom/webidl/AudioContext.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,29 @@
* liability, trademark and document use rules apply.
*/

callback DecodeSuccessCallback = void (AudioBuffer decodedData);
callback DecodeErrorCallback = void (DOMException error);

enum AudioContextState {
"suspended",
"running",
"closed"
};

dictionary PeriodicWaveConstraints {
boolean disableNormalization = false;
};

[Constructor,
Constructor(AudioChannel audioChannelType),
Pref="dom.webaudio.enabled"]
interface AudioContext : EventTarget {
interface AudioContext : BaseAudioContext {

// Bug 1324545: readonly attribute double outputLatency;
// Bug 1324545: AudioTimestamp getOutputTimestamp ();

readonly attribute AudioDestinationNode destination;
readonly attribute float sampleRate;
readonly attribute double currentTime;
readonly attribute AudioListener listener;
readonly attribute AudioContextState state;
[Throws]
Promise<void> suspend();
[Throws]
Promise<void> resume();
[Throws]
Promise<void> close();
attribute EventHandler onstatechange;

[NewObject, Throws]
AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);

[Throws]
Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
optional DecodeSuccessCallback successCallback,
optional DecodeErrorCallback errorCallback);

// AudioNode creation
[NewObject, Throws]
AudioBufferSourceNode createBufferSource();

[NewObject, Throws]
ConstantSourceNode createConstantSource();

[NewObject, Throws]
MediaStreamAudioDestinationNode createMediaStreamDestination();

[NewObject, Throws]
ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
optional unsigned long numberOfInputChannels = 2,
optional unsigned long numberOfOutputChannels = 2);

[NewObject, Throws]
StereoPannerNode createStereoPanner();
[NewObject, Throws]
AnalyserNode createAnalyser();
[NewObject, Throws, UnsafeInPrerendering]
MediaElementAudioSourceNode createMediaElementSource(HTMLMediaElement mediaElement);

[NewObject, Throws, UnsafeInPrerendering]
MediaStreamAudioSourceNode createMediaStreamSource(MediaStream mediaStream);
[NewObject, Throws]
GainNode createGain();
[NewObject, Throws]
DelayNode createDelay(optional double maxDelayTime = 1);
[NewObject, Throws]
BiquadFilterNode createBiquadFilter();
[NewObject, Throws]
IIRFilterNode createIIRFilter(sequence<double> feedforward, sequence<double> feedback);
[NewObject, Throws]
WaveShaperNode createWaveShaper();
[NewObject, Throws]
PannerNode createPanner();
[NewObject, Throws]
ConvolverNode createConvolver();

[NewObject, Throws]
ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
[NewObject, Throws]
ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
// Bug 1324548: MediaStreamTrackAudioSourceNode createMediaStreamTrackSource (AudioMediaStreamTrack mediaStreamTrack);

[NewObject, Throws]
DynamicsCompressorNode createDynamicsCompressor();

[NewObject, Throws]
OscillatorNode createOscillator();
[NewObject, Throws]
PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag, optional PeriodicWaveConstraints constraints);

MediaStreamAudioDestinationNode createMediaStreamDestination();
};

// Mozilla extensions
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/AudioNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface AudioNode : EventTarget {
[Throws]
void disconnect(AudioParam destination, unsigned long output);

readonly attribute AudioContext context;
readonly attribute BaseAudioContext context;
readonly attribute unsigned long numberOfInputs;
readonly attribute unsigned long numberOfOutputs;

Expand Down
100 changes: 100 additions & 0 deletions dom/webidl/BaseAudioContext.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/#idl-def-BaseAudioContext
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/

callback DecodeSuccessCallback = void (AudioBuffer decodedData);
callback DecodeErrorCallback = void (DOMException error);

enum AudioContextState {
"suspended",
"running",
"closed"
};

interface BaseAudioContext : EventTarget {
readonly attribute AudioDestinationNode destination;
readonly attribute float sampleRate;
readonly attribute double currentTime;
readonly attribute AudioListener listener;
readonly attribute AudioContextState state;
// Bug 1324552: readonly attribute double baseLatency;

[Throws]
Promise<void> resume();

attribute EventHandler onstatechange;

[NewObject, Throws]
AudioBuffer createBuffer (unsigned long numberOfChannels,
unsigned long length,
float sampleRate);

[Throws]
Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
optional DecodeSuccessCallback successCallback,
optional DecodeErrorCallback errorCallback);

// AudioNode creation
[NewObject, Throws]
AudioBufferSourceNode createBufferSource();

[NewObject, Throws]
ConstantSourceNode createConstantSource();

[NewObject, Throws]
ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
optional unsigned long numberOfInputChannels = 2,
optional unsigned long numberOfOutputChannels = 2);

[NewObject, Throws]
AnalyserNode createAnalyser();

[NewObject, Throws]
GainNode createGain();

[NewObject, Throws]
DelayNode createDelay(optional double maxDelayTime = 1);

[NewObject, Throws]
BiquadFilterNode createBiquadFilter();

[NewObject, Throws]
IIRFilterNode createIIRFilter(sequence<double> feedforward, sequence<double> feedback);

[NewObject, Throws]
WaveShaperNode createWaveShaper();

[NewObject, Throws]
PannerNode createPanner();

[NewObject, Throws]
StereoPannerNode createStereoPanner();

[NewObject, Throws]
ConvolverNode createConvolver();

[NewObject, Throws]
ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);

[NewObject, Throws]
ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);

[NewObject, Throws]
DynamicsCompressorNode createDynamicsCompressor();

[NewObject, Throws]
OscillatorNode createOscillator();

[NewObject, Throws]
PeriodicWave createPeriodicWave(Float32Array real,
Float32Array imag,
optional PeriodicWaveConstraints constraints);
};
2 changes: 1 addition & 1 deletion dom/webidl/BiquadFilterNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dictionary BiquadFilterOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional BiquadFilterOptions options)]
Constructor(BaseAudioContext context, optional BiquadFilterOptions options)]
interface BiquadFilterNode : AudioNode {

attribute BiquadFilterType type;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ChannelMergerNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ dictionary ChannelMergerOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional ChannelMergerOptions options)]
Constructor(BaseAudioContext context, optional ChannelMergerOptions options)]
interface ChannelMergerNode : AudioNode {
};
2 changes: 1 addition & 1 deletion dom/webidl/ChannelSplitterNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dictionary ChannelSplitterOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional ChannelSplitterOptions options)]
Constructor(BaseAudioContext context, optional ChannelSplitterOptions options)]
interface ChannelSplitterNode : AudioNode {

};
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ConstantSourceNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dictionary ConstantSourceOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional ConstantSourceOptions options)]
Constructor(BaseAudioContext context, optional ConstantSourceOptions options)]
interface ConstantSourceNode : AudioNode {
readonly attribute AudioParam offset;
attribute EventHandler onended;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ConvolverNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dictionary ConvolverOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional ConvolverOptions options)]
Constructor(BaseAudioContext context, optional ConvolverOptions options)]
interface ConvolverNode : AudioNode {

[SetterThrows]
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/DelayNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dictionary DelayOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional DelayOptions options)]
Constructor(BaseAudioContext context, optional DelayOptions options)]
interface DelayNode : AudioNode {

readonly attribute AudioParam delayTime;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/DynamicsCompressorNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dictionary DynamicsCompressorOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional DynamicsCompressorOptions options)]
Constructor(BaseAudioContext context, optional DynamicsCompressorOptions options)]
interface DynamicsCompressorNode : AudioNode {

readonly attribute AudioParam threshold; // in Decibels
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/GainNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dictionary GainOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, optional GainOptions options)]
Constructor(BaseAudioContext context, optional GainOptions options)]
interface GainNode : AudioNode {

readonly attribute AudioParam gain;
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/IIRFilterNode.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dictionary IIRFilterOptions : AudioNodeOptions {
};

[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, IIRFilterOptions options)]
Constructor(BaseAudioContext context, IIRFilterOptions options)]
interface IIRFilterNode : AudioNode {
void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse);
};
Expand Down
Loading

0 comments on commit 59d9a61

Please sign in to comment.