Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html

Issue 1464673002: Support multichannel audio stream more than 2 in MediaStreamDestinationNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed intdentation Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html
diff --git a/third_party/WebKit/ManualTests/webaudio/multichannel.html b/third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html
similarity index 75%
copy from third_party/WebKit/ManualTests/webaudio/multichannel.html
copy to third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html
index d5958520c2f0f8d65fea74e05c0e5347a6122a53..218697d4144333d9f4808815563e8461a1636750 100644
--- a/third_party/WebKit/ManualTests/webaudio/multichannel.html
+++ b/third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
- <title>Test multichannel support.</title>
+ <title>Test multichannel support for MediaStreamDestination.</title>
<style type="text/css">
body {
margin: 2em;
@@ -15,26 +15,29 @@
padding: 1em;
font-size: 1em;
}
+ #eError {
+ font-family: Arial;
+ margin: 0.75em;
+ color: red;
+ }
</style>
</head>
<body>
- <h1>Test Multichannel Audio Output</h1>
+ <h1>Test Multichannel Audio Output for MediaStreamDestination</h1>
+
+ <p><strong>NOTE: This test requires HTTP server.</strong></p>
- <p>Tests that multichannel audio output (> 8 channels) is working correctly.
- This test cannot be run with an offline audio context because it requires
- an actual audio hardware with the multichannel capability.</p>
+ <p>This test is for multichannel (&gt; 2 channels) support for
+ MediaStreamDestination. This test cannot be run with an offline audio
+ context because the node is not compatible with the offline context.</p>
<p>Press "Start Test Tone" to run the test. You should hear an one-second
sine tone from all the available audio output channels from the channel 1
to the last channel.</p>
- <p>Note that this test only works on OSX because CoreAudio driver supports
- the multichannel streams (more than 2) on a single audio device whereas
- other platforms do not.</p>
-
- <p>CRBUG issue: <a href="https://code.google.com/p/chromium/issues/detail?id=424795" target="_blank">
- 424795</a></p>
+ <p>CRBUG issue: <a href="https://code.google.com/p/chromium/issues/detail?id=557185" target="_blank">
+ 557185</a></p>
<div class="manual-test-ui">
<p>Max Channel Count: <span id="eMaxChannelCount">2</span></p>
@@ -42,13 +45,15 @@
<button id="eButton" onclick="startTestTones()">Start Test Tone</button>
</div>
+ <div id="eError"></div>
+
<script type="text/javascript">
// Silent interval between the test tones.
var testToneInterval = 0.1;
// The safe range for the equal loudness of sinusoid is roughly between
// 200 ~ 1000Hz, which is A3(57) ~ C6(84). In this test, the starting
- // pitch is 220Hz and the interval is the whole tone. (2 MIDI pitch)
+ // pitch is 220Hz and the interval is the whole tone. (2 MIDI pitch)
// With 16 speakers, the last test tone will play the MIDI pitch of
// F6(89), which is 1396Hz.
var startMIDIPitch = 57;
@@ -56,20 +61,28 @@
var eMaxChannelCount = document.querySelector('#eMaxChannelCount');
var eButton = document.querySelector('#eButton');
var eChannelIndex = document.querySelector('#eChannelIndex');
+ var eError = document.querySelector('#eError');
var context = new AudioContext();
+ var mediaStreamDestination = context.createMediaStreamDestination();
+
var maxChannelCount = context.destination.maxChannelCount;
- // Sets the destination properties for multichannel access.
- context.destination.channelCount = maxChannelCount;
- context.destination.channelCountMode = 'explicit';
- context.destination.channelInterpretation = 'discrete';
+ try {
+ mediaStreamDestination.channelCount = maxChannelCount;
+ } catch (error) {
+ eError.textContent = error;
+ }
+
+ var audioElement = new Audio();
+ audioElement.src = URL.createObjectURL(mediaStreamDestination.stream);
+ audioElement.play();
// The ChannelMerger for the individual channel access.
var merger = context.createChannelMerger(maxChannelCount);
merger.channelCountMode = 'explicit';
merger.channelInterpretation = 'discrete';
- merger.connect(context.destination);
+ merger.connect(mediaStreamDestination);
eMaxChannelCount.textContent = maxChannelCount;
@@ -78,6 +91,9 @@
return 440 * Math.pow(2, (midiPitch - 69) / 12);
}
+ // A global storage to keep the OSC reference alive.
+ var oscs = [];
+
// Play a test tone for the specified amount of duration at the channel.
function playTestToneAtChannel(channelIndex, gain, duration) {
var osc = context.createOscillator();
@@ -99,7 +115,7 @@
// The channel index starts from 1.
eChannelIndex.textContent = 'Channel #' + (channelIndex + 1);
-
+
var now = context.currentTime;
var toneDuration = duration - testToneInterval;
@@ -111,6 +127,10 @@
osc.start(now);
osc.stop(now + duration);
+
+ // Push osc to keep the reference alive. Otherwise |osc| will be
+ // collected and the |onended| event won't be fired.
+ oscs.push(osc);
}
// When the button is clicked the button to produce the test sound,
@@ -120,7 +140,7 @@
function startTestTones() {
eButton.disabled = true;
- // Math.SQRT1_2(=0.707..) is -3dB. This is necessary because 1.0
+ // Math.SQRT1_2(=0.707..) is -3dB. This is necessary because 1.0
// amplitude can cause overload/distortion on some speakers.
playTestToneAtChannel(0, Math.SQRT1_2, 1.0);
}

Powered by Google App Engine
This is Rietveld 408576698