forked from mirrors/gecko-dev
Bug 1882685 use async/await to manage asynchronicity in some PannerNode tests r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D203083
This commit is contained in:
parent
9bc3553854
commit
8a163574a0
2 changed files with 28 additions and 50 deletions
|
|
@ -17,15 +17,7 @@ var types = [
|
|||
"HRTF"
|
||||
]
|
||||
|
||||
var finished = 2 * types.length;
|
||||
|
||||
function finish() {
|
||||
if (!--finished) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function testMono(type) {
|
||||
async function testMono(type) {
|
||||
var ac = new OfflineAudioContext(1, BUF_SIZE, 44100);
|
||||
|
||||
// A sine to be used to fill the buffers
|
||||
|
|
@ -76,13 +68,11 @@ function testMono(type) {
|
|||
monoBuffer.getChannelData(0)[i] = gain * monoBuffer.getChannelData(0)[i];
|
||||
}
|
||||
|
||||
ac.startRendering().then(function(buffer) {
|
||||
compareBuffers(buffer, monoBuffer);
|
||||
finish();
|
||||
});
|
||||
const buffer = await ac.startRendering();
|
||||
compareBuffers(buffer, monoBuffer);
|
||||
}
|
||||
|
||||
function testStereo(type) {
|
||||
async function testStereo(type) {
|
||||
var ac = new OfflineAudioContext(2, BUF_SIZE, 44100);
|
||||
|
||||
// A sine to be used to fill the buffers
|
||||
|
|
@ -126,23 +116,21 @@ function testStereo(type) {
|
|||
|
||||
panner3.connect(ac.destination);
|
||||
|
||||
ac.startRendering().then(function(buffer) {
|
||||
compareBuffers(buffer, stereoBuffer);
|
||||
finish();
|
||||
});
|
||||
const buffer = await ac.startRendering();
|
||||
compareBuffers(buffer, stereoBuffer);
|
||||
}
|
||||
|
||||
function test(type) {
|
||||
testMono(type);
|
||||
testStereo(type);
|
||||
async function test(type) {
|
||||
await testMono(type)
|
||||
await testStereo(type);
|
||||
}
|
||||
|
||||
addLoadEvent(function() {
|
||||
types.forEach(test);
|
||||
add_task(async function() {
|
||||
for (const panningModel of types) {
|
||||
await test(panningModel);
|
||||
}
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -14,15 +14,7 @@ var types = [
|
|||
"HRTF"
|
||||
]
|
||||
|
||||
var finished = types.length;
|
||||
|
||||
function finish() {
|
||||
if (!--finished) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function test(type) {
|
||||
async function test(type) {
|
||||
var ac = new OfflineAudioContext(1, 128, 44100);
|
||||
var osc = ac.createOscillator();
|
||||
var panner = ac.createPanner();
|
||||
|
|
@ -37,27 +29,25 @@ function test(type) {
|
|||
|
||||
osc.start();
|
||||
|
||||
ac.startRendering().then(function(buffer) {
|
||||
var silence = true;
|
||||
var array = buffer.getChannelData(0);
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
if (array[i] != 0) {
|
||||
ok(false, "Found noise in the buffer.");
|
||||
silence = false;
|
||||
}
|
||||
const buffer = await ac.startRendering()
|
||||
|
||||
var silence = true;
|
||||
var array = buffer.getChannelData(0);
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
if (array[i] != 0) {
|
||||
ok(false, "Found noise in the buffer.");
|
||||
silence = false;
|
||||
}
|
||||
ok(silence, "The buffer is silent.");
|
||||
finish();
|
||||
});
|
||||
}
|
||||
ok(silence, "The buffer is silent.");
|
||||
}
|
||||
|
||||
|
||||
addLoadEvent(function() {
|
||||
types.forEach(test);
|
||||
add_task(async function() {
|
||||
for (const panningModel of types) {
|
||||
await test(panningModel);
|
||||
}
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue