| Index: third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html b/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
|
| index c100b8f4d629e8f188ba8484cd97c2aba019e9a7..958cb1206b07a46a45525e48e442f8cc2eb304f6 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
|
| @@ -12,29 +12,27 @@
|
| description('Test ChannelMergerNode behavior on dynamic input change.');
|
| window.jsTestIsAsync = true;
|
|
|
| - var sampleRate = 44100;
|
| - var numberOfChannels = 2;
|
| + var renderQuantum = 128;
|
|
|
| - // The test needs the long render length (20 seconds) to capture the
|
| - // disconnection which happens after starting the rendering.
|
| - var renderLength = sampleRate * 20;
|
| + var numberOfChannels = 2;
|
| + var sampleRate = 44100;
|
| + var renderDuration = 0.5;
|
| + var disconnectTime = 0.5 * renderDuration;
|
|
|
| var audit = Audit.createTaskRunner();
|
|
|
| // Task: Check if the merger outputs a silent channel when an input is
|
| // disconnected.
|
| audit.defineTask('silent-disconnect', function (done) {
|
| - var context = new OfflineAudioContext(
|
| - numberOfChannels, renderLength, sampleRate
|
| - );
|
| + var context = new OfflineAudioContext(numberOfChannels, renderDuration * sampleRate, sampleRate);
|
| var merger = context.createChannelMerger();
|
| var source1 = context.createBufferSource();
|
| var source2 = context.createBufferSource();
|
|
|
| - // Create and assign a mono testing buffer.
|
| - var bufferDCOffset = createTestingAudioBuffer(context, 1, renderLength);
|
| - source1.buffer = bufferDCOffset;
|
| - source2.buffer = bufferDCOffset;
|
| + // Create and assign a constant buffer.
|
| + var bufferDCOffset = createConstantBuffer(context, 1, 1);
|
| + source1.buffer = source2.buffer = bufferDCOffset;
|
| + source1.loop = source2.loop = true;
|
|
|
| // Connect the output of source into the 4th input of merger. The merger
|
| // should produce 6 channel output.
|
| @@ -44,22 +42,31 @@
|
| source1.start();
|
| source2.start();
|
|
|
| - // When the rendering begins, disconnect |source2| as soon as possible.
|
| - context.onstatechange = function () {
|
| - if (context.state === 'running')
|
| - source2.disconnect();
|
| - };
|
| + // Schedule the disconnection of |source2| at the half of render duration.
|
| + context.suspend(disconnectTime).then(function () {
|
| + source2.disconnect();
|
| + context.resume();
|
| + });
|
|
|
| context.startRendering().then(function (buffer) {
|
| -
|
| // The entire first channel of the output should be 1.
|
| Should('Channel #0', buffer.getChannelData(0)).beConstantValueOf(1);
|
|
|
| + // Calculate the first zero index in the second channel.
|
| + var channel1 = buffer.getChannelData(1);
|
| + var disconnectIndex = disconnectTime * sampleRate;
|
| + disconnectIndex -= (disconnectIndex) % renderQuantum;
|
| + var firstZeroIndex = channel1.findIndex(function (element, index) {
|
| + if (element === 0)
|
| + return index;
|
| + });
|
| +
|
| // The second channel should contain 1, and 0 after the disconnection.
|
| - Should('Channel #1', buffer.getChannelData(1)).containValues([1, 0]);
|
| + Should('Channel #1', channel1).containValues([1, 0]);
|
| + Should('The index of first zero in the channel #1', firstZeroIndex)
|
| + .beEqualTo(disconnectIndex);
|
|
|
| - done();
|
| - });
|
| + }).then(done);
|
| });
|
|
|
| audit.defineTask('finish', function (done) {
|
| @@ -67,10 +74,7 @@
|
| done();
|
| });
|
|
|
| - audit.runTasks(
|
| - 'silent-disconnect',
|
| - 'finish'
|
| - );
|
| + audit.runTasks();
|
|
|
| successfullyParsed = true;
|
| </script>
|
|
|