mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=938450 rename compareBuffers to compareChannels & add compareBuffers f=ehsan
--HG-- extra : transplant_source : %93W%BC%84%FF%10%9B%F5%CD5%98%0E%F0/%F2R%B9W%1E%94
This commit is contained in:
parent
29b88874bc
commit
dace222cfd
@ -51,8 +51,7 @@ addLoadEvent(function() {
|
||||
ctx.addEventListener("complete", function(e) {
|
||||
ok(e instanceof OfflineAudioCompletionEvent, "Correct event received");
|
||||
is(e.renderedBuffer.numberOfChannels, 2, "Correct expected number of buffers");
|
||||
compareBuffers(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||
compareBuffers(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||
compareBuffers(e.renderedBuffer, buf);
|
||||
|
||||
expectException(function() {
|
||||
ctx.startRendering();
|
||||
|
@ -42,9 +42,9 @@ addLoadEvent(function() {
|
||||
return function(e) {
|
||||
is(e.inputBuffer.numberOfChannels, 1, "Correct input channel count");
|
||||
if (i < 4) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), buffer.getChannelData(i));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(i));
|
||||
} else {
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
}
|
||||
e.target.onaudioprocess = null;
|
||||
++channelsSeen;
|
||||
|
@ -37,7 +37,7 @@ function onAudioProcess(e) {
|
||||
var ctx = e.target.context;
|
||||
var expected = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
|
||||
applySignal(expected, offset);
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), expected.getChannelData(0));
|
||||
compareBuffers(e.inputBuffer, expected);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
count++;
|
||||
|
@ -33,7 +33,7 @@ function onDelayOutput(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), sourceOutput);
|
||||
compareChannels(e.inputBuffer.getChannelData(0), sourceOutput);
|
||||
e.target.onaudioprocess = null;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ function onAudioProcess(e) {
|
||||
var ctx = e.target.context;
|
||||
var expected = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
|
||||
applySignal(expected, offset);
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), expected.getChannelData(0));
|
||||
compareBuffers(e.inputBuffer, expected);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
count++;
|
||||
|
@ -74,7 +74,7 @@ function onDelayOutput(e) {
|
||||
var ctx = e.target.context;
|
||||
var expected = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
|
||||
applySignal(expected, delayBufferOffset);
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), expected.getChannelData(0));
|
||||
compareBuffers(e.inputBuffer, expected);
|
||||
e.target.onaudioprocess = null;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ addLoadEvent(function() {
|
||||
ctx.startRendering();
|
||||
ctx.oncomplete = function(e) {
|
||||
is(e.renderedBuffer.numberOfChannels, 2, "Correct expected number of buffers");
|
||||
compareBuffers(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||
compareBuffers(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||
compareChannels(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||
compareChannels(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
@ -30,10 +30,10 @@ addLoadEvent(function() {
|
||||
ctx.startRendering();
|
||||
ctx.oncomplete = function(e) {
|
||||
is(e.renderedBuffer.numberOfChannels, 6, "Correct expected number of buffers");
|
||||
compareBuffers(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||
compareBuffers(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||
compareChannels(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||
compareChannels(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||
for (var i = 2; i < 6; ++i) {
|
||||
compareBuffers(e.renderedBuffer.getChannelData(i), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.renderedBuffer.getChannelData(i), emptyBuffer.getChannelData(0));
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
|
@ -43,8 +43,8 @@ function startTest() {
|
||||
oscillator2.connect(gain);
|
||||
|
||||
processor.onaudioprocess = function(e) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(0),
|
||||
new Float32Array(bufferSize));
|
||||
compareChannels(e.inputBuffer.getChannelData(0),
|
||||
new Float32Array(bufferSize));
|
||||
e.target.onaudioprocess = null;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ function onTestOutput(e) {
|
||||
}
|
||||
|
||||
for (var i = 0; i < 2; ++i) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(i), referenceOutput[i]);
|
||||
compareChannels(e.inputBuffer.getChannelData(i), referenceOutput[i]);
|
||||
}
|
||||
e.target.onaudioprocess = null;
|
||||
e.target.disconnect();
|
||||
|
@ -79,10 +79,10 @@ addLoadEvent(function() {
|
||||
// Because of the initial latency added by the second script processor node,
|
||||
// we will never see any generated audio frames in the first callback.
|
||||
var emptyBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareBuffers(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
compareBuffers(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareBuffers(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
|
||||
sp.onaudioprocess = function(e) {
|
||||
is(e.target, sp, "Correct event target");
|
||||
@ -97,12 +97,12 @@ addLoadEvent(function() {
|
||||
|
||||
var firstNonZero = findFirstNonZeroSample(e.inputBuffer);
|
||||
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
||||
compareBuffers(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
||||
compareBuffers(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
||||
compareBuffers(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareBuffers(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
||||
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
||||
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero);
|
||||
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
|
||||
if (firstNonZero == 0) {
|
||||
// If we did not experience any delays, the test is done!
|
||||
@ -122,12 +122,12 @@ addLoadEvent(function() {
|
||||
is(e.outputBuffer.length, 2048, "Correct length for the output buffer");
|
||||
is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer");
|
||||
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 0, firstNonZero, 0, 2048 - firstNonZero);
|
||||
compareBuffers(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 0, firstNonZero, 0, 2048 - firstNonZero);
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero);
|
||||
compareBuffers(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero);
|
||||
compareBuffers(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareBuffers(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 0, firstNonZero, 0, 2048 - firstNonZero);
|
||||
compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 0, firstNonZero, 0, 2048 - firstNonZero);
|
||||
compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero);
|
||||
compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero);
|
||||
compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0));
|
||||
|
||||
sp.onaudioprocess = null;
|
||||
|
||||
|
@ -54,16 +54,16 @@ addLoadEvent(function() {
|
||||
sp.onaudioprocess = function(e) {
|
||||
is(e.inputBuffer.numberOfChannels, 3, "Should be correctly down-mixed to three channels");
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(i), buffer.getChannelData(i));
|
||||
compareChannels(e.inputBuffer.getChannelData(i), buffer.getChannelData(i));
|
||||
}
|
||||
|
||||
// On the next iteration, we'll get a silence buffer
|
||||
sp.onaudioprocess = function(e) {
|
||||
var emptyBuffer = context.createBuffer(1, 2048, context.sampleRate);
|
||||
is(e.inputBuffer.numberOfChannels, 3, "Should be correctly up-mixed to three channels");
|
||||
compareBuffers(e.inputBuffer.getChannelData(0), monoBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(0), monoBuffer.getChannelData(0));
|
||||
for (var i = 1; i < 3; ++i) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(i), emptyBuffer.getChannelData(0));
|
||||
compareChannels(e.inputBuffer.getChannelData(i), emptyBuffer.getChannelData(0));
|
||||
}
|
||||
|
||||
sp.onaudioprocess = null;
|
||||
|
@ -27,14 +27,14 @@ function fuzzyCompare(a, b) {
|
||||
return Math.abs(a - b) < 9e-3;
|
||||
}
|
||||
|
||||
function compareBuffers(buf1, buf2,
|
||||
function compareChannels(buf1, buf2,
|
||||
/*optional*/ offset,
|
||||
/*optional*/ length,
|
||||
/*optional*/ sourceOffset,
|
||||
/*optional*/ destOffset,
|
||||
/*optional*/ skipLengthCheck) {
|
||||
if (!skipLengthCheck) {
|
||||
is(buf1.length, buf2.length, "Buffers must have the same length");
|
||||
is(buf1.length, buf2.length, "Channels must have the same length");
|
||||
}
|
||||
if (length == undefined) {
|
||||
length = buf1.length - (offset || 0);
|
||||
@ -60,6 +60,29 @@ function compareBuffers(buf1, buf2,
|
||||
destOffset);
|
||||
}
|
||||
|
||||
function compareBuffers(got, expected) {
|
||||
if (got.numberOfChannels != expected.numberOfChannels) {
|
||||
is(got.numberOfChannels, expected.numberOfChannels,
|
||||
"Correct number of buffer channels");
|
||||
return;
|
||||
}
|
||||
if (got.length != expected.length) {
|
||||
is(got.length, expected.length,
|
||||
"Correct buffer length");
|
||||
return;
|
||||
}
|
||||
if (got.sampleRate != expected.sampleRate) {
|
||||
is(got.sampleRate, expected.sampleRate,
|
||||
"Correct sample rate");
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < got.numberOfChannels; ++i) {
|
||||
compareChannels(got.getChannelData(i), expected.getChannelData(i),
|
||||
0, got.length, 0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
function getEmptyBuffer(context, length) {
|
||||
return context.createBuffer(gTest.numberOfChannels, length, context.sampleRate);
|
||||
}
|
||||
@ -148,11 +171,7 @@ function runTest()
|
||||
sp.onaudioprocess = function(e) {
|
||||
var expectedBuffer = expectedBuffers.shift();
|
||||
testLength += expectedBuffer.length;
|
||||
is(e.inputBuffer.numberOfChannels, expectedBuffer.numberOfChannels,
|
||||
"Correct number of input buffer channels");
|
||||
for (var i = 0; i < e.inputBuffer.numberOfChannels; ++i) {
|
||||
compareBuffers(e.inputBuffer.getChannelData(i), expectedBuffer.getChannelData(i));
|
||||
}
|
||||
compareBuffers(e.inputBuffer, expectedBuffer);
|
||||
if (expectedBuffers.length == 0) {
|
||||
sp.onaudioprocess = null;
|
||||
callback();
|
||||
@ -173,7 +192,7 @@ function runTest()
|
||||
is(e.renderedBuffer.numberOfChannels, expectedBuffer.numberOfChannels,
|
||||
"Correct number of input buffer channels");
|
||||
for (var i = 0; i < e.renderedBuffer.numberOfChannels; ++i) {
|
||||
compareBuffers(e.renderedBuffer.getChannelData(i),
|
||||
compareChannels(e.renderedBuffer.getChannelData(i),
|
||||
expectedBuffer.getChannelData(i),
|
||||
undefined,
|
||||
expectedBuffer.length,
|
||||
|
Loading…
Reference in New Issue
Block a user