Bug 873553 - Part 10: Allow creating OfflineAudioContexts with arbitrary sampling rates; r=roc

--HG--
extra : rebase_source : 99758cbe05b83d34734e4df11f30ebbbd12811df
This commit is contained in:
Ehsan Akhgari 2013-05-24 13:11:32 -04:00
parent c74b3d338f
commit 6d703a83b0
2 changed files with 10 additions and 3 deletions

View File

@ -108,8 +108,8 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
return nullptr;
}
if (aSampleRate != IdealAudioRate()) {
// TODO: Add support for running OfflineAudioContext at other sampling rates
if (aSampleRate <= 0.0f) {
// The DOM binding protects us against infinity and NaN
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return nullptr;
}

View File

@ -13,7 +13,7 @@
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
var ctx = new OfflineAudioContext(2, 100, (new AudioContext()).sampleRate);
var ctx = new OfflineAudioContext(2, 100, 22050);
ok(ctx instanceof EventTarget, "OfflineAudioContexts must be EventTargets");
var buf = ctx.createBuffer(2, 100, ctx.sampleRate);
@ -23,6 +23,13 @@ addLoadEvent(function() {
}
}
expectException(function() {
new OfflineAudioContext(2, 100, 0);
}, DOMException.SYNTAX_ERR);
expectException(function() {
new OfflineAudioContext(2, 100, -1);
}, DOMException.SYNTAX_ERR);
var src = ctx.createBufferSource();
src.buffer = buf;
src.start(0);