b=921675 use maximum instead of current delay for tail time because delay can increase faster than time passes r=ehsan

--HG--
extra : rebase_source : b74864829e5fa0cdfbd555d93d2c71dd656f2258
This commit is contained in:
Karl Tomlinson 2013-10-01 09:50:03 +13:00
Родитель 78889ff332
Коммит 960af07a87
4 изменённых файлов: 74 добавлений и 2 удалений

Просмотреть файл

@ -88,7 +88,7 @@ public:
if (mProcessor.BufferChannelCount() &&
mLeftOverData == INT32_MIN &&
aStream->AllInputsFinished()) {
mLeftOverData = mProcessor.CurrentDelayFrames() - WEBAUDIO_BLOCK_SIZE;
mLeftOverData = mProcessor.MaxDelayFrames() - WEBAUDIO_BLOCK_SIZE;
if (mLeftOverData > 0) {
nsRefPtr<PlayingRefChanged> refchanged =

Просмотреть файл

@ -37,7 +37,7 @@ public:
void Reset() { mBuffer.Clear(); };
double CurrentDelayFrames() const { return mCurrentDelay; }
int MaxDelayFrames() const { return mMaxDelayFrames; }
int BufferChannelCount() const { return mBuffer.Length(); }
private:

Просмотреть файл

@ -76,6 +76,7 @@ support-files =
[test_delayNodeAtMax.html]
[test_delayNodeCycles.html]
[test_delayNodeSmallMaxDelay.html]
[test_delayNodeTailIncrease.html]
[test_delayNodeWithGain.html]
[test_dynamicsCompressorNode.html]
[test_gainNode.html]

Просмотреть файл

@ -0,0 +1,71 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test increasing delay of DelayNode after input finishes</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">
SimpleTest.waitForExplicitFinish();
const signalLength = 100;
const bufferSize = 1024;
// Delay should be long enough to allow CC to run
const delayBufferCount = 50;
const delayLength = delayBufferCount * bufferSize + 700;
var count = 0;
function applySignal(buffer, offset) {
for (var i = 0; i < signalLength; ++i) {
buffer.getChannelData(0)[offset + i] = Math.cos(Math.PI * i / signalLength);
}
}
function onAudioProcess(e) {
switch(count) {
case 5:
SpecialPowers.forceGC();
SpecialPowers.forceCC();
break;
case delayBufferCount:
var offset = delayLength - count * bufferSize;
var ctx = e.target.context;
var expected = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
applySignal(expected, offset);
compareBuffers(e.inputBuffer.getChannelData(0), expected.getChannelData(0));
SimpleTest.finish();
}
count++;
}
function startTest() {
var ctx = new AudioContext();
var processor = ctx.createScriptProcessor(bufferSize, 1, 0);
processor.onaudioprocess = onAudioProcess;
// Switch on delay at a time in the future.
var delayDuration = delayLength / ctx.sampleRate;
var delayStartTime = (delayLength - bufferSize) / ctx.sampleRate;
var delay = ctx.createDelay(delayDuration);
delay.delayTime.setValueAtTime(delayDuration, delayStartTime);
delay.connect(processor);
// Short signal that finishes before switching to long delay
var buffer = ctx.createBuffer(1, signalLength, ctx.sampleRate);
applySignal(buffer, 0);
var source = ctx.createBufferSource();
source.buffer = buffer;
source.start();
source.connect(delay);
};
startTest();
</script>
</pre>
</body>
</html>