<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[248090] branches/safari-608-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/248090">248090</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2019-07-31 18:23:03 -0700 (Wed, 31 Jul 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/248046">r248046</a>. rdar://problem/53788952

    Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
    https://bugs.webkit.org/show_bug.cgi?id=200248
    <rdar://problem/53411051>

    Reviewed by Eric Carlson.

    Source/WebCore:

    When a track's number of channels changes, MediaStreamAudioSourceNode is expected
    to update its MultiChannelResampler and its output number of channels.
    MultiChannelResampler expects to have the same number of channels as the output
    but it is not always the case since the channel numbers are changed in different threads
    and locks do not help there.

    Instead, whenever detecting that the number of channels do not match, render silence
    and wait for the next rendering where the number of channels should again match.

    Add internals API to change the number of channels from 2 to 1 or 1 to 2
    to allow testing that code path (iOS only as MacOS audio capture is in UIProcess).
    Covered by updated test.

    * Modules/webaudio/MediaElementAudioSourceNode.cpp:
    (WebCore::MediaElementAudioSourceNode::process):
    * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
    (WebCore::MediaStreamAudioSourceNode::process):
    * platform/audio/MultiChannelResampler.cpp:
    (WebCore::MultiChannelResampler::process):
    * platform/mediastream/RealtimeMediaSource.h:
    * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
    (WebCore::MockRealtimeAudioSourceMac::reconfigure):
    * platform/mock/MockRealtimeAudioSource.cpp:
    (WebCore::MockRealtimeAudioSource::setChannelCount):
    * platform/mock/MockRealtimeAudioSource.h:
    (isType):
    * platform/mock/MockRealtimeVideoSource.h:
    * testing/Internals.cpp:
    (WebCore::Internals::setMockAudioTrackChannelNumber):
    * testing/Internals.h:
    * testing/Internals.idl:

    LayoutTests:

    * fast/mediastream/getUserMedia-webaudio-expected.txt:
    * fast/mediastream/getUserMedia-webaudio.html:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248046 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari608branchLayoutTestsChangeLog">branches/safari-608-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari608branchLayoutTestsfastmediastreamgetUserMediawebaudioexpectedtxt">branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio-expected.txt</a></li>
<li><a href="#branchessafari608branchLayoutTestsfastmediastreamgetUserMediawebaudiohtml">branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio.html</a></li>
<li><a href="#branchessafari608branchSourceWebCoreChangeLog">branches/safari-608-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari608branchSourceWebCoreModuleswebaudioMediaElementAudioSourceNodecpp">branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodecpp">branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformaudioMultiChannelResamplercpp">branches/safari-608-branch/Source/WebCore/platform/audio/MultiChannelResampler.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmediastreamRealtimeMediaSourceh">branches/safari-608-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm">branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmockMockRealtimeAudioSourcecpp">branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmockMockRealtimeAudioSourceh">branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.h</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmockMockRealtimeVideoSourceh">branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeVideoSource.h</a></li>
<li><a href="#branchessafari608branchSourceWebCoretestingInternalscpp">branches/safari-608-branch/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoretestingInternalsh">branches/safari-608-branch/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#branchessafari608branchSourceWebCoretestingInternalsidl">branches/safari-608-branch/Source/WebCore/testing/Internals.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari608branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/LayoutTests/ChangeLog (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/LayoutTests/ChangeLog 2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/LayoutTests/ChangeLog    2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -1,5 +1,68 @@
</span><span class="cx"> 2019-07-31  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r248046. rdar://problem/53788952
+
+    Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
+    https://bugs.webkit.org/show_bug.cgi?id=200248
+    <rdar://problem/53411051>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    When a track's number of channels changes, MediaStreamAudioSourceNode is expected
+    to update its MultiChannelResampler and its output number of channels.
+    MultiChannelResampler expects to have the same number of channels as the output
+    but it is not always the case since the channel numbers are changed in different threads
+    and locks do not help there.
+    
+    Instead, whenever detecting that the number of channels do not match, render silence
+    and wait for the next rendering where the number of channels should again match.
+    
+    Add internals API to change the number of channels from 2 to 1 or 1 to 2
+    to allow testing that code path (iOS only as MacOS audio capture is in UIProcess).
+    Covered by updated test.
+    
+    * Modules/webaudio/MediaElementAudioSourceNode.cpp:
+    (WebCore::MediaElementAudioSourceNode::process):
+    * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
+    (WebCore::MediaStreamAudioSourceNode::process):
+    * platform/audio/MultiChannelResampler.cpp:
+    (WebCore::MultiChannelResampler::process):
+    * platform/mediastream/RealtimeMediaSource.h:
+    * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+    (WebCore::MockRealtimeAudioSourceMac::reconfigure):
+    * platform/mock/MockRealtimeAudioSource.cpp:
+    (WebCore::MockRealtimeAudioSource::setChannelCount):
+    * platform/mock/MockRealtimeAudioSource.h:
+    (isType):
+    * platform/mock/MockRealtimeVideoSource.h:
+    * testing/Internals.cpp:
+    (WebCore::Internals::setMockAudioTrackChannelNumber):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * fast/mediastream/getUserMedia-webaudio-expected.txt:
+    * fast/mediastream/getUserMedia-webaudio.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-31  Youenn Fablet  <youenn@apple.com>
+
+            Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
+            https://bugs.webkit.org/show_bug.cgi?id=200248
+            <rdar://problem/53411051>
+
+            Reviewed by Eric Carlson.
+
+            * fast/mediastream/getUserMedia-webaudio-expected.txt:
+            * fast/mediastream/getUserMedia-webaudio.html:
+
+2019-07-31  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r248037. rdar://problem/53764079
</span><span class="cx"> 
</span><span class="cx">     AX: Re-enable accessibility/set-selected-text-range-after-newline.html test.
</span></span></pre></div>
<a id="branchessafari608branchLayoutTestsfastmediastreamgetUserMediawebaudioexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio-expected.txt (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio-expected.txt       2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio-expected.txt  2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Plugging in getUserMedia audio stream into Web Audio 
</span><ins>+PASS Web Audio should work even if number of channels of a track increases from 1 to 2 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari608branchLayoutTestsfastmediastreamgetUserMediawebaudiohtml"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio.html (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio.html       2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/LayoutTests/fast/mediastream/getUserMedia-webaudio.html  2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -38,6 +38,33 @@
</span><span class="cx">         });
</span><span class="cx">     });
</span><span class="cx"> }, "Plugging in getUserMedia audio stream into Web Audio");
</span><ins>+
+function waitFor(duration)
+{
+    return new Promise(resolve => setTimeout(resolve, duration));
+}
+
+promise_test(async (test) => {
+    if (!window.internals)
+        return Promise.reject("Internals API required");
+
+    const stream = await navigator.mediaDevices.getUserMedia({ audio: {deviceId: true}});
+    internals.setMockAudioTrackChannelNumber(stream.getAudioTracks()[0], 1);
+
+    var audioContext = new webkitAudioContext();
+    var script = audioContext.createScriptProcessor(2048, 1, 1);
+    let source = audioContext.createMediaStreamSource(stream);
+    source.connect(script);
+    script.connect(audioContext.destination);
+
+    await waitFor(200);
+
+    internals.setMockAudioTrackChannelNumber(stream.getAudioTracks()[0], 2);
+    await waitFor(200);
+
+    source.disconnect(script);
+    script.disconnect(audioContext.destination);
+}, "Web Audio should work even if number of channels of a track increases from 1 to 2");
</ins><span class="cx">         </script>
</span><span class="cx">     </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/ChangeLog      2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog 2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -1,5 +1,97 @@
</span><span class="cx"> 2019-07-31  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r248046. rdar://problem/53788952
+
+    Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
+    https://bugs.webkit.org/show_bug.cgi?id=200248
+    <rdar://problem/53411051>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    When a track's number of channels changes, MediaStreamAudioSourceNode is expected
+    to update its MultiChannelResampler and its output number of channels.
+    MultiChannelResampler expects to have the same number of channels as the output
+    but it is not always the case since the channel numbers are changed in different threads
+    and locks do not help there.
+    
+    Instead, whenever detecting that the number of channels do not match, render silence
+    and wait for the next rendering where the number of channels should again match.
+    
+    Add internals API to change the number of channels from 2 to 1 or 1 to 2
+    to allow testing that code path (iOS only as MacOS audio capture is in UIProcess).
+    Covered by updated test.
+    
+    * Modules/webaudio/MediaElementAudioSourceNode.cpp:
+    (WebCore::MediaElementAudioSourceNode::process):
+    * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
+    (WebCore::MediaStreamAudioSourceNode::process):
+    * platform/audio/MultiChannelResampler.cpp:
+    (WebCore::MultiChannelResampler::process):
+    * platform/mediastream/RealtimeMediaSource.h:
+    * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+    (WebCore::MockRealtimeAudioSourceMac::reconfigure):
+    * platform/mock/MockRealtimeAudioSource.cpp:
+    (WebCore::MockRealtimeAudioSource::setChannelCount):
+    * platform/mock/MockRealtimeAudioSource.h:
+    (isType):
+    * platform/mock/MockRealtimeVideoSource.h:
+    * testing/Internals.cpp:
+    (WebCore::Internals::setMockAudioTrackChannelNumber):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * fast/mediastream/getUserMedia-webaudio-expected.txt:
+    * fast/mediastream/getUserMedia-webaudio.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-31  Youenn Fablet  <youenn@apple.com>
+
+            Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
+            https://bugs.webkit.org/show_bug.cgi?id=200248
+            <rdar://problem/53411051>
+
+            Reviewed by Eric Carlson.
+
+            When a track's number of channels changes, MediaStreamAudioSourceNode is expected
+            to update its MultiChannelResampler and its output number of channels.
+            MultiChannelResampler expects to have the same number of channels as the output
+            but it is not always the case since the channel numbers are changed in different threads
+            and locks do not help there.
+
+            Instead, whenever detecting that the number of channels do not match, render silence
+            and wait for the next rendering where the number of channels should again match.
+
+            Add internals API to change the number of channels from 2 to 1 or 1 to 2
+            to allow testing that code path (iOS only as MacOS audio capture is in UIProcess).
+            Covered by updated test.
+
+            * Modules/webaudio/MediaElementAudioSourceNode.cpp:
+            (WebCore::MediaElementAudioSourceNode::process):
+            * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
+            (WebCore::MediaStreamAudioSourceNode::process):
+            * platform/audio/MultiChannelResampler.cpp:
+            (WebCore::MultiChannelResampler::process):
+            * platform/mediastream/RealtimeMediaSource.h:
+            * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+            (WebCore::MockRealtimeAudioSourceMac::reconfigure):
+            * platform/mock/MockRealtimeAudioSource.cpp:
+            (WebCore::MockRealtimeAudioSource::setChannelCount):
+            * platform/mock/MockRealtimeAudioSource.h:
+            (isType):
+            * platform/mock/MockRealtimeVideoSource.h:
+            * testing/Internals.cpp:
+            (WebCore::Internals::setMockAudioTrackChannelNumber):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2019-07-31  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r248037. rdar://problem/53764079
</span><span class="cx"> 
</span><span class="cx">     AX: Re-enable accessibility/set-selected-text-range-after-newline.html test.
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreModuleswebaudioMediaElementAudioSourceNodecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp       2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp  2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -137,6 +137,10 @@
</span><span class="cx">         outputBus->zero();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    if (m_sourceNumberOfChannels != outputBus->numberOfChannels()) {
+        outputBus->zero();
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (AudioSourceProvider* provider = mediaElement().audioSourceProvider()) {
</span><span class="cx">         if (m_multiChannelResampler.get()) {
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp        2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp   2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -126,6 +126,10 @@
</span><span class="cx">         outputBus->zero();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    if (m_sourceNumberOfChannels != outputBus->numberOfChannels()) {
+        outputBus->zero();
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (m_multiChannelResampler.get()) {
</span><span class="cx">         ASSERT(m_sourceSampleRate != sampleRate());
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformaudioMultiChannelResamplercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/audio/MultiChannelResampler.cpp (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/audio/MultiChannelResampler.cpp       2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/audio/MultiChannelResampler.cpp  2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -102,6 +102,8 @@
</span><span class="cx"> 
</span><span class="cx"> void MultiChannelResampler::process(AudioSourceProvider* provider, AudioBus* destination, size_t framesToProcess)
</span><span class="cx"> {
</span><ins>+    ASSERT(m_numberOfChannels == destination->numberOfChannels());
+
</ins><span class="cx">     // The provider can provide us with multi-channel audio data. But each of our single-channel resamplers (kernels)
</span><span class="cx">     // below requires a provider which provides a single unique channel of data.
</span><span class="cx">     // channelProvider wraps the original multi-channel provider and dishes out one channel at a time.
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmediastreamRealtimeMediaSourceh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h     2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h        2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -172,6 +172,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool isIsolated() const { return false; }
</span><span class="cx"> 
</span><ins>+    virtual bool isMockSource() const { return false; }
</ins><span class="cx">     virtual bool isCaptureSource() const { return false; }
</span><span class="cx">     virtual CaptureDevice::DeviceType deviceType() const { return CaptureDevice::DeviceType::Unknown; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm 2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm    2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx"> 
</span><span class="cx">     const int bytesPerFloat = sizeof(Float32);
</span><span class="cx">     const int bitsPerByte = 8;
</span><del>-    const int channelCount = 2;
</del><ins>+    const int channelCount = m_channelCount;
</ins><span class="cx">     const bool isFloat = true;
</span><span class="cx">     const bool isBigEndian = false;
</span><span class="cx">     const bool isNonInterleaved = true;
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmockMockRealtimeAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp      2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp 2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -98,6 +98,15 @@
</span><span class="cx">     return m_currentSettings.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MockRealtimeAudioSource::setChannelCount(unsigned channelCount)
+{
+    if (channelCount > 2)
+        return;
+
+    m_channelCount = channelCount;
+    settingsDidChange(RealtimeMediaSourceSettings::Flag::SampleRate);
+}
+
</ins><span class="cx"> const RealtimeMediaSourceCapabilities& MockRealtimeAudioSource::capabilities()
</span><span class="cx"> {
</span><span class="cx">     if (!m_capabilities) {
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmockMockRealtimeAudioSourceh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.h (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.h        2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeAudioSource.h   2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx">     static CaptureSourceOrError create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints*);
</span><span class="cx">     virtual ~MockRealtimeAudioSource();
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT void setChannelCount(unsigned);
+
</ins><span class="cx"> protected:
</span><span class="cx">     MockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt);
</span><span class="cx"> 
</span><span class="lines">@@ -64,11 +66,13 @@
</span><span class="cx">     CaptureDevice::DeviceType deviceType() const final { return CaptureDevice::DeviceType::Microphone; }
</span><span class="cx"> 
</span><span class="cx">     void delaySamples(Seconds) final;
</span><ins>+    bool isMockSource() const final { return true; }
</ins><span class="cx"> 
</span><span class="cx">     void tick();
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     Ref<WorkQueue> m_workQueue;
</span><ins>+    unsigned m_channelCount { 2 };
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     Optional<RealtimeMediaSourceCapabilities> m_capabilities;
</span><span class="lines">@@ -85,4 +89,9 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::MockRealtimeAudioSource)
+    static bool isType(const WebCore::RealtimeMediaSource& source) { return source.isCaptureSource() && source.isMockSource() && source.deviceType() == WebCore::CaptureDevice::DeviceType::Microphone; }
+SPECIALIZE_TYPE_TRAITS_END()
+
+
</ins><span class="cx"> #endif // ENABLE(MEDIA_STREAM)
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmockMockRealtimeVideoSourceh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeVideoSource.h        2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/platform/mock/MockRealtimeVideoSource.h   2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -78,6 +78,8 @@
</span><span class="cx"> 
</span><span class="cx">     void generatePresets() final;
</span><span class="cx"> 
</span><ins>+    bool isMockSource() const final { return true; }
+
</ins><span class="cx">     // OrientationNotifier::Observer
</span><span class="cx">     void orientationChanged(int orientation) final;
</span><span class="cx">     void monitorOrientation(OrientationNotifier&) final;
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.cpp (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/testing/Internals.cpp  2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.cpp     2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -4694,6 +4694,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><ins>+void Internals::setMockAudioTrackChannelNumber(MediaStreamTrack& track, unsigned short channelNumber)
+{
+    auto& source = track.source();
+    if (!is<MockRealtimeAudioSource>(source))
+        return;
+    downcast<MockRealtimeAudioSource>(source).setChannelCount(channelNumber);
+}
</ins><span class="cx"> 
</span><span class="cx"> void Internals::setCameraMediaStreamTrackOrientation(MediaStreamTrack& track, int orientation)
</span><span class="cx"> {
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.h (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/testing/Internals.h    2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.h       2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -707,6 +707,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><ins>+    void setMockAudioTrackChannelNumber(MediaStreamTrack&, unsigned short);
</ins><span class="cx">     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
</span><span class="cx">     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
</span><span class="cx">     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.idl (248089 => 248090)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/testing/Internals.idl  2019-08-01 01:22:57 UTC (rev 248089)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.idl     2019-08-01 01:23:03 UTC (rev 248090)
</span><span class="lines">@@ -693,6 +693,7 @@
</span><span class="cx">     [Conditional=WEB_RTC] void setH264HardwareEncoderAllowed(boolean allowed);
</span><span class="cx">     [Conditional=WEB_RTC] void applyRotationForOutgoingVideoSources(RTCPeerConnection connection);
</span><span class="cx"> 
</span><ins>+    [Conditional=MEDIA_STREAM] void setMockAudioTrackChannelNumber(MediaStreamTrack track, unsigned short count);
</ins><span class="cx">     [Conditional=MEDIA_STREAM] void setShouldInterruptAudioOnPageVisibilityChange(boolean shouldInterrupt);
</span><span class="cx">     [Conditional=MEDIA_STREAM] void setCameraMediaStreamTrackOrientation(MediaStreamTrack track, short orientation);
</span><span class="cx">     [Conditional=MEDIA_STREAM] void observeMediaStreamTrack(MediaStreamTrack track);
</span></span></pre>
</div>
</div>

</body>
</html>