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.
This commit is contained in:
Ehsan Akhgari 2013-06-23 19:22:10 -04:00
parent fcf0bd180b
commit cbebfc17c9
18 changed files with 92 additions and 20 deletions

View File

@ -36,7 +36,7 @@ o11[i] = Math.sin(i * 127);
}
return o10;
}(); } catch(e) { Logger.error(Logger.comment(e)); }
try { o3.noteOff(-1) } catch(e) { Logger.error(Logger.comment(e)); }
try { o3.stop(-1) } catch(e) { Logger.error(Logger.comment(e)); }
/* [Exception... "An attempt was made to use an object that is not, or is no longer, usable" code: "11" nsresult: "0x8053000b (InvalidStateError)" location: "file:///Users/cdiehl/dev/projects/peach/Peach/Utilities/JS/undefined.js Line: 602"] */
try { o3.channelCountMode = 'explicit'; } catch(e) { Logger.error(Logger.comment(e)); }
try { o12 = o1.createBiquadFilter(); } catch(e) { Logger.error(Logger.comment(e)); }
@ -78,4 +78,4 @@ o22[i] = Math.sin(i * 63);
}
return o21;
}(); } catch(e) { Logger.error(Logger.comment(e)); }
</script>
</script>

View File

@ -7,8 +7,8 @@
function boom()
{
var bufferSource = AudioContext().createScriptProcessor().context.createBufferSource();
bufferSource.noteGrainOn(0, 0, 0);
bufferSource.noteOff(562949953421313);
bufferSource.start(0, 0, 0);
bufferSource.stop(562949953421313);
}
</script></head>

View File

@ -1,6 +1,6 @@
<script>
try { o1 = new window.OfflineAudioContext(1, 10, 44100); } catch(e) { }
try { o6 = o1.createJavaScriptNode(0, 0, 2); } catch(e) { }
try { o6 = o1.createScriptProcessor(0, 0, 2); } catch(e) { }
try { o8 = o1.createBufferSource(); } catch(e) { }
try { o8.connect(o1.destination); } catch(e) { }
try { o8.connect(o6) } catch(e) { }
@ -11,4 +11,4 @@ o22 = o21.getChannelData(0);
return o21;
}()
; } catch(e) { }
</script>
</script>

View File

@ -23,7 +23,7 @@ BufferSource1.buffer=function(){
}();
Gain0.connect(Panner0);
Panner0.panningModel=0;
Panner0.panningModel="equalpower";
setTimeout(function(){

View File

@ -10,6 +10,7 @@
#include "AudioDestinationNode.h"
#include "WebAudioUtils.h"
#include "blink/Biquad.h"
#include "mozilla/Preferences.h"
namespace mozilla {
namespace dom {
@ -201,6 +202,26 @@ BiquadFilterNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
void
BiquadFilterNode::SetType(BiquadFilterType aType)
{
if (!Preferences::GetBool("media.webaudio.legacy.BiquadFilterNode")) {
// Do not accept the alternate enum values unless the legacy pref
// has been turned on.
switch (aType) {
case BiquadFilterType::_0:
case BiquadFilterType::_1:
case BiquadFilterType::_2:
case BiquadFilterType::_3:
case BiquadFilterType::_4:
case BiquadFilterType::_5:
case BiquadFilterType::_6:
case BiquadFilterType::_7:
// Do nothing in order to emulate setting an invalid enum value.
return;
default:
// Shut up the compiler warning
break;
}
}
// Handle the alternate enum values
switch (aType) {
case BiquadFilterType::_0: aType = BiquadFilterType::Lowpass; break;

View File

@ -14,6 +14,7 @@
#include "mozilla/dom/PannerNodeBinding.h"
#include "ThreeDPoint.h"
#include "mozilla/WeakPtr.h"
#include "mozilla/Preferences.h"
#include "WebAudioUtils.h"
#include <set>
@ -42,6 +43,20 @@ public:
}
void SetPanningModel(PanningModelType aPanningModel)
{
if (!Preferences::GetBool("media.webaudio.legacy.PannerNode")) {
// Do not accept the alternate enum values unless the legacy pref
// has been turned on.
switch (aPanningModel) {
case PanningModelType::_0:
case PanningModelType::_1:
// Do nothing in order to emulate setting an invalid enum value.
return;
default:
// Shut up the compiler warning
break;
}
}
// Handle the alternate enum values
switch (aPanningModel) {
case PanningModelType::_0: aPanningModel = PanningModelType::Equalpower; break;
@ -61,6 +76,21 @@ public:
}
void SetDistanceModel(DistanceModelType aDistanceModel)
{
if (!Preferences::GetBool("media.webaudio.legacy.PannerNode")) {
// Do not accept the alternate enum values unless the legacy pref
// has been turned on.
switch (aDistanceModel) {
case DistanceModelType::_0:
case DistanceModelType::_1:
case DistanceModelType::_2:
// Do nothing in order to emulate setting an invalid enum value.
return;
default:
// Shut up the compiler warning
break;
}
}
// Handle the alternate enum values
switch (aDistanceModel) {
case DistanceModelType::_0: aDistanceModel = DistanceModelType::Linear; break;

View File

@ -161,7 +161,7 @@ function timeToSampleFrame(time, sampleRate) {
return Math.floor(0.5 + time * sampleRate);
}
// Compute the number of sample frames consumed by noteGrainOn with
// Compute the number of sample frames consumed by start with
// the specified |grainOffset|, |duration|, and |sampleRate|.
function grainLengthInSampleFrames(grainOffset, duration, sampleRate) {
var startFrame = timeToSampleFrame(grainOffset, sampleRate);

View File

@ -58,7 +58,7 @@ function createGraph(context, nodeCount) {
// Start the source
time[k] = k * timeStep;
bufferSource[k].noteOn(time[k]);
bufferSource[k].start(time[k]);
}
}

View File

@ -16,7 +16,7 @@ addLoadEvent(function() {
var source = ctx.createBufferSource();
var buffer = ctx.createBuffer(2, 2048, 8000);
source.playbackRate.setTargetValueAtTime(0, 2, 3);
source.playbackRate.setTargetAtTime(0, 2, 3);
var sp = ctx.createScriptProcessor();
source.connect(sp);
sp.connect(ctx.destination);

View File

@ -17,7 +17,7 @@ try { (document.body || document.documentElement).appendChild(o0); } catch(e) {
try { o1 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { }
try { o1.startRendering(); } catch(e) { }
try { o1.listener.dopplerFactor = 1; } catch(e) { }
try { o2 = o1.createJavaScriptNode(); } catch(e) { }
try { o2 = o1.createScriptProcessor(); } catch(e) { }
try { o3 = o1.createChannelMerger(4); } catch(e) { }
try { o1.listener.dopplerFactor = 3; } catch(e) { }
try { o1.listener.setPosition(0, 134217728, 64) } catch(e) { }

View File

@ -12,7 +12,7 @@
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
SimpleTest.waitForExplicitFinish();
try { o1 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { }
try { o2 = o1.createJavaScriptNode(); } catch(e) { }
try { o2 = o1.createScriptProcessor(); } catch(e) { }
try { o4 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { }
try { o5 = o1.createChannelSplitter(4); } catch(e) { }
try { o7 = o4.createScriptProcessor(1024, 4, 1); } catch(e) { }

View File

@ -55,7 +55,7 @@ function runTest() {
bufferSource.connect(convolver);
convolver.connect(context.destination);
bufferSource.noteOn(0);
bufferSource.start(0);
context.oncomplete = checkConvolvedResult(trianglePulse);
context.startRendering();

View File

@ -38,12 +38,12 @@ interface AudioBufferSourceNode : AudioNode {
[PrefControlled]
partial interface AudioBufferSourceNode {
// Same as start()
[Throws]
[Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"]
void noteOn(double when);
[Throws]
[Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"]
void noteGrainOn(double when, double grainOffset, double grainDuration);
[Throws]
[Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"]
// Same as stop()
void noteOff(double when);
};

View File

@ -78,15 +78,15 @@ interface AudioContext : EventTarget {
[PrefControlled]
partial interface AudioContext {
// Same as createGain()
[Creator]
[Creator,Pref="media.webaudio.legacy.AudioContext"]
GainNode createGainNode();
// Same as createDelay()
[Creator, Throws]
[Creator, Throws, Pref="media.webaudio.legacy.AudioContext"]
DelayNode createDelayNode(optional double maxDelayTime = 1);
// Same as createScriptProcessor()
[Creator, Throws]
[Creator, Throws, Pref="media.webaudio.legacy.AudioContext"]
ScriptProcessorNode createJavaScriptNode(optional unsigned long bufferSize = 0,
optional unsigned long numberOfInputChannels = 2,
optional unsigned long numberOfOutputChannels = 2);

View File

@ -46,7 +46,7 @@ interface AudioParam {
[PrefControlled]
partial interface AudioParam {
// Same as setTargetAtTime()
[Throws]
[Throws,Pref="media.webaudio.legacy.AudioParam"]
void setTargetValueAtTime(float target, double startTime, double timeConstant);
};

View File

@ -45,13 +45,21 @@ interface BiquadFilterNode : AudioNode {
*/
[PrefControlled]
partial interface BiquadFilterNode {
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short LOWPASS = 0;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short HIGHPASS = 1;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short BANDPASS = 2;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short LOWSHELF = 3;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short HIGHSHELF = 4;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short PEAKING = 5;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short NOTCH = 6;
[Pref="media.webaudio.legacy.BiquadFilterNode"]
const unsigned short ALLPASS = 7;
};

View File

@ -57,11 +57,16 @@ interface PannerNode : AudioNode {
*/
[PrefControlled]
partial interface PannerNode {
[Pref="media.webaudio.legacy.PannerNode"]
const unsigned short EQUALPOWER = 0;
[Pref="media.webaudio.legacy.PannerNode"]
const unsigned short HRTF = 1;
[Pref="media.webaudio.legacy.PannerNode"]
const unsigned short LINEAR_DISTANCE = 0;
[Pref="media.webaudio.legacy.PannerNode"]
const unsigned short INVERSE_DISTANCE = 1;
[Pref="media.webaudio.legacy.PannerNode"]
const unsigned short EXPONENTIAL_DISTANCE = 2;
};

View File

@ -130,3 +130,11 @@ user_pref("network.http.bypass-cachelock-threshold", 200000);
// Enable Gamepad
user_pref("dom.gamepad.enabled", true);
user_pref("dom.gamepad.non_standard_events.enabled", true);
// Enable Web Audio legacy APIs
user_pref("media.webaudio.legacy.AudioBufferSourceNode", true);
user_pref("media.webaudio.legacy.AudioContext", true);
user_pref("media.webaudio.legacy.AudioParam", true);
user_pref("media.webaudio.legacy.BiquadFilterNode", true);
user_pref("media.webaudio.legacy.PannerNode", true);
user_pref("media.webaudio.legacy.OscillatorNode", true);