mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877125 - Handle the case where the expected number of channels for the offline AudioDestinationNode and the actual input number of channels do not match; r=roc
--HG-- extra : rebase_source : 432c10fe039b24b1aea1d0329ebef37f9e62cd0a
This commit is contained in:
parent
028ad03f99
commit
b60b4f5031
@ -60,7 +60,10 @@ public:
|
||||
// Record our input buffer
|
||||
MOZ_ASSERT(mWriteIndex < mLength, "How did this happen?");
|
||||
const uint32_t duration = std::min(WEBAUDIO_BLOCK_SIZE, mLength - mWriteIndex);
|
||||
for (uint32_t i = 0; i < mInputChannels.Length(); ++i) {
|
||||
const uint32_t commonChannelCount = std::min(mInputChannels.Length(),
|
||||
aInput.mChannelData.Length());
|
||||
// First, copy as many channels in the input as we have
|
||||
for (uint32_t i = 0; i < commonChannelCount; ++i) {
|
||||
if (aInput.IsNull()) {
|
||||
PodZero(mInputChannels[i] + mWriteIndex, duration);
|
||||
} else {
|
||||
@ -80,6 +83,10 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
// Then, silence all of the remaining channels
|
||||
for (uint32_t i = commonChannelCount; i < mInputChannels.Length(); ++i) {
|
||||
PodZero(mInputChannels[i] + mWriteIndex, duration);
|
||||
}
|
||||
mWriteIndex += duration;
|
||||
|
||||
if (mWriteIndex == mLength) {
|
||||
|
@ -62,6 +62,8 @@ MOCHITEST_FILES := \
|
||||
test_mixingRules.html \
|
||||
test_nodeToParamConnection.html \
|
||||
test_OfflineAudioContext.html \
|
||||
test_offlineDestinationChannelCountLess.html \
|
||||
test_offlineDestinationChannelCountMore.html \
|
||||
test_pannerNode.html \
|
||||
test_scriptProcessorNode.html \
|
||||
test_scriptProcessorNodeChannelCount.html \
|
||||
|
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test OfflineAudioContext with a channel count less than the specified number</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();
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||
var ctx = new OfflineAudioContext(2, 100, 22050);
|
||||
|
||||
var buf = ctx.createBuffer(6, 100, ctx.sampleRate);
|
||||
for (var i = 0; i < 6; ++i) {
|
||||
for (var j = 0; j < 100; ++j) {
|
||||
buf.getChannelData(i)[j] = Math.sin(2 * Math.PI * 200 * j / ctx.sampleRate);
|
||||
}
|
||||
}
|
||||
|
||||
var src = ctx.createBufferSource();
|
||||
src.buffer = buf;
|
||||
src.start(0);
|
||||
src.connect(ctx.destination);
|
||||
ctx.destination.channelCountMode = "max";
|
||||
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));
|
||||
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test OfflineAudioContext with a channel count less than the specified number</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();
|
||||
addLoadEvent(function() {
|
||||
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||
var ctx = new OfflineAudioContext(6, 100, 22050);
|
||||
|
||||
var buf = ctx.createBuffer(2, 100, ctx.sampleRate);
|
||||
for (var i = 0; i < 2; ++i) {
|
||||
for (var j = 0; j < 100; ++j) {
|
||||
buf.getChannelData(i)[j] = Math.sin(2 * Math.PI * 200 * j / ctx.sampleRate);
|
||||
}
|
||||
}
|
||||
var emptyBuffer = ctx.createBuffer(1, 100, ctx.sampleRate);
|
||||
|
||||
var src = ctx.createBufferSource();
|
||||
src.buffer = buf;
|
||||
src.start(0);
|
||||
src.connect(ctx.destination);
|
||||
ctx.destination.channelCountMode = "max";
|
||||
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));
|
||||
for (var i = 2; i < 6; ++i) {
|
||||
compareBuffers(e.renderedBuffer.getChannelData(i), emptyBuffer.getChannelData(0));
|
||||
}
|
||||
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user