Bug 875596 - Properly handle AudioParam SetCurve automation events with a 0 duration; r=roc

--HG--
rename : content/media/webaudio/test/test_audioParamSetCurveAtTime.html => content/media/webaudio/test/test_audioParamSetCurveAtTimeZeroDuration.html
This commit is contained in:
Ehsan Akhgari 2013-05-24 13:19:47 -04:00
parent 957cbbdf9f
commit fd75086ad5
5 changed files with 75 additions and 0 deletions

View File

@ -393,6 +393,10 @@ public:
static float ExtractValueFromCurve(double startTime, float* aCurve, uint32_t aCurveLength, double duration, double t)
{
if (t >= startTime + duration) {
// After the duration, return the last curve value
return aCurve[aCurveLength - 1];
}
double ratio = (t - startTime) / duration;
MOZ_ASSERT(ratio >= 0.0, "Ratio can never be negative here");
if (ratio >= 1.0) {

View File

@ -0,0 +1,12 @@
<script>
try { o1 = new AudioContext(); } catch(e) { }
try { o6 = o1.createGain(); } catch(e) { }
try { o8 = o1.createBufferSource(); } catch(e) { }
try { o6.gain.setValueCurveAtTime(Float32Array(7), 0, 0) } catch(e) { }
try { o8.connect(o6, 0, 0) } catch(e) { }
try { o8.buffer = function() {
o19 = o1.createBuffer(1, 1, 76309);
for(var i=0; i<1; ++i) { }
return o19;
}(); } catch(e) { }
</script>

View File

@ -21,3 +21,4 @@ load 874934.html
load 874952.html
load 875144.html
load 875402.html
load 875596.html

View File

@ -31,6 +31,7 @@ MOCHITEST_FILES := \
test_audioParamExponentialRamp.html \
test_audioParamLinearRamp.html \
test_audioParamSetCurveAtTime.html \
test_audioParamSetCurveAtTimeZeroDuration.html \
test_audioParamSetTargetAtTime.html \
test_audioParamTimelineDestinationOffset.html \
test_audioBufferSourceNode.html \

View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test AudioParam.linearRampToValue</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="webaudio.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var T0 = 0;
var gTest = {
length: 2048,
numberOfChannels: 1,
createGraph: function(context) {
var sourceBuffer = context.createBuffer(1, 2048, context.sampleRate);
for (var i = 0; i < 2048; ++i) {
sourceBuffer.getChannelData(0)[i] = 1;
}
var source = context.createBufferSource();
source.buffer = sourceBuffer;
var gain = context.createGain();
gain.gain.setValueCurveAtTime(this.curve, this.T0, 0);
source.connect(gain);
source.start(0);
return gain;
},
createExpectedBuffers: function(context) {
this.T0 = 1024 / context.sampleRate;
this.curve = new Float32Array(100);
for (var i = 0; i < 100; ++i) {
this.curve[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
}
var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
for (var i = 0; i < 1024; ++i) {
expectedBuffer.getChannelData(0)[i] = 1;
}
for (var i = 1024; i < 2048; ++i) {
expectedBuffer.getChannelData(0)[i] = this.curve[99];
}
return expectedBuffer;
},
};
runTest();
</script>
</pre>
</body>
</html>