Skip to content

Commit

Permalink
Bug 1526860 [wpt PR 15214] - Round up to the next render quantum for …
Browse files Browse the repository at this point in the history
…suspend, a=testonly

Automatic update from web-platform-tests
Round up to the next render quantum for suspend

OfflineAudioContext.suspend rounds the time up to the next render
quantum instead of down.  It is sometimes confusing when suspend
occurs before the given time, which is different from how everything
else works in WebAudio.

A few tests need to be fixed because they computed the boundary by
rounding down instead of up.  One test needed to be adjusted because
the times were rounded to different boundaries instead of the same
boundary.

See also WebAudio/web-audio-api#1822

Bug: 927895
Change-Id: Ie6685c620dd38eb2a059901d13b907764ba1a2db
Reviewed-on: https://chromium-review.googlesource.com/c/1450536
Reviewed-by: Kent Tamura <tkentchromium.org>
Reviewed-by: Hongchan Choi <hongchanchromium.org>
Commit-Queue: Raymond Toy <rtoychromium.org>
Cr-Commit-Position: refs/heads/master{#630346}

--

wpt-commits: 1b1a627e597f15b60327191799b8081beac2a3cd
wpt-pr: 15214

UltraBlame original commit: 5255301763d07829b256b6fc8022064ab01e500f
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 60d45ab commit 4e8543a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
// Calculate the index for disconnection.
function getDisconnectIndex(disconnectTime) {
let disconnectIndex = disconnectTime * sampleRate;
return disconnectIndex -= (disconnectIndex) % renderQuantum;
disconnectIndex = renderQuantum *
Math.floor((disconnectIndex + renderQuantum - 1) / renderQuantum);
return disconnectIndex;
}

// Get the index of value change.
Expand All @@ -35,7 +37,6 @@

// Task 1: test disconnect(AudioParam) method.
audit.define('disconnect(AudioParam)', (task, should) => {

// Creates a buffer source with value [1] and then connect it to two
// gain nodes in series. The output of the buffer source is lowered by
// half
Expand Down Expand Up @@ -89,14 +90,12 @@
should(channelData, 'Channel #0').containValues([2.25, 1.5]);
should(valueChangeIndex, 'The index of value change')
.beEqualTo(disconnectIndex);

})
.then(() => task.done());
});

// Task 2: test disconnect(AudioParam, output) method.
audit.define('disconnect(AudioParam, output)', (task, should) => {

// Create a 2-channel buffer source with [1, 2] in each channel and
// make a serial connection through gain1 and gain 2. The make the
// buffer source half with a gain node and connect it to a 2-output
Expand Down Expand Up @@ -168,7 +167,6 @@
valueChangeIndexCh1,
'The index of value change in channel #1')
.beEqualTo(disconnectIndex);

})
.then(() => task.done());
});
Expand All @@ -191,19 +189,28 @@
gain3.connect(context.destination);

// gain1 is not connected to gain3.gain. Exception should be thrown.
should(function() {
gain1.disconnect(gain3.gain);
}, 'gain1.disconnect(gain3.gain)').throw(DOMException, 'InvalidAccessError');
should(
function() {
gain1.disconnect(gain3.gain);
},
'gain1.disconnect(gain3.gain)')
.throw(DOMException, 'InvalidAccessError');

// When the output index is good but the destination is invalid.
should(function() {
splitter.disconnect(gain1.gain, 1);
}, 'splitter.disconnect(gain1.gain, 1)').throw(DOMException, 'InvalidAccessError');
should(
function() {
splitter.disconnect(gain1.gain, 1);
},
'splitter.disconnect(gain1.gain, 1)')
.throw(DOMException, 'InvalidAccessError');

// When both arguments are wrong, throw IndexSizeError first.
should(function() {
splitter.disconnect(gain1.gain, 2);
}, 'splitter.disconnect(gain1.gain, 2)').throw(DOMException, 'IndexSizeError');
should(
function() {
splitter.disconnect(gain1.gain, 2);
},
'splitter.disconnect(gain1.gain, 2)')
.throw(DOMException, 'IndexSizeError');

task.done();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
// Calculate the first zero index in the second channel.
let channel1 = buffer.getChannelData(1);
let disconnectIndex = disconnectTime * sampleRate;
disconnectIndex -= (disconnectIndex) % renderQuantum;
disconnectIndex = renderQuantum *
Math.floor(
(disconnectIndex + renderQuantum - 1) / renderQuantum);
let firstZeroIndex = channel1.findIndex(function(element, index) {
if (element === 0)
return index;
Expand All @@ -70,7 +72,6 @@
should(
firstZeroIndex, 'The index of first zero in the channel #1')
.beEqualTo(disconnectIndex);

})
.then(() => task.done());
});
Expand Down

0 comments on commit 4e8543a

Please sign in to comment.