Title: [267036] trunk
Revision
267036
Author
[email protected]
Date
2020-09-14 13:31:34 -0700 (Mon, 14 Sep 2020)

Log Message

AudioDestinationCocoa should stop hardcoding the number of output channels to 2
https://bugs.webkit.org/show_bug.cgi?id=216491

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline existing test.

* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt:

Source/WebCore:

Stop hardcoding the number of output channels in AudioDestinationCocoa and instead use the AudioDestinationNode's
number of output channels.

* platform/audio/cocoa/AudioDestinationCocoa.cpp:
(WebCore::AudioDestination::create):
(WebCore::AudioDestinationCocoa::AudioDestinationCocoa):
(WebCore::AudioDestinationCocoa::numberOfOutputChannels const):
(WebCore::AudioDestinationCocoa::setAudioStreamBasicDescription):
(): Deleted.
* platform/audio/cocoa/AudioDestinationCocoa.h:
* platform/mock/MockAudioDestinationCocoa.cpp:
(WebCore::MockAudioDestinationCocoa::MockAudioDestinationCocoa):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (267035 => 267036)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-14 20:31:34 UTC (rev 267036)
@@ -1,3 +1,14 @@
+2020-09-14  Chris Dumez  <[email protected]>
+
+        AudioDestinationCocoa should stop hardcoding the number of output channels to 2
+        https://bugs.webkit.org/show_bug.cgi?id=216491
+
+        Reviewed by Darin Adler.
+
+        Rebaseline existing test.
+
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt:
+
 2020-09-14  Sam Weinig  <[email protected]>
 
         [WebIDL] Replace 'serializable' with '[Default] object toJSON()'

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt (267035 => 267036)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt	2020-09-14 20:31:34 UTC (rev 267036)
@@ -3,7 +3,7 @@
 PASS Executing "test" 
 PASS Audit report 
 PASS > [test] Test convolver with real-time context 
-FAIL X SNR is not greater than or equal to 88.457. Got 76.95278846153181. assert_true: expected true got false
+FAIL X SNR is not greater than or equal to 88.457. Got 77.00623887904952. assert_true: expected true got false
 FAIL < [test] 1 out of 1 assertions were failed. assert_true: expected true got false
 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
 

Modified: trunk/Source/WebCore/ChangeLog (267035 => 267036)


--- trunk/Source/WebCore/ChangeLog	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/Source/WebCore/ChangeLog	2020-09-14 20:31:34 UTC (rev 267036)
@@ -1,3 +1,23 @@
+2020-09-14  Chris Dumez  <[email protected]>
+
+        AudioDestinationCocoa should stop hardcoding the number of output channels to 2
+        https://bugs.webkit.org/show_bug.cgi?id=216491
+
+        Reviewed by Darin Adler.
+
+        Stop hardcoding the number of output channels in AudioDestinationCocoa and instead use the AudioDestinationNode's
+        number of output channels.
+
+        * platform/audio/cocoa/AudioDestinationCocoa.cpp:
+        (WebCore::AudioDestination::create):
+        (WebCore::AudioDestinationCocoa::AudioDestinationCocoa):
+        (WebCore::AudioDestinationCocoa::numberOfOutputChannels const):
+        (WebCore::AudioDestinationCocoa::setAudioStreamBasicDescription):
+        (): Deleted.
+        * platform/audio/cocoa/AudioDestinationCocoa.h:
+        * platform/mock/MockAudioDestinationCocoa.cpp:
+        (WebCore::MockAudioDestinationCocoa::MockAudioDestinationCocoa):
+
 2020-09-14  Fujii Hironori  <[email protected]>
 
         [WinCairo][MediaFoundation] r264188 introduced linker warning: LNK4199: /DELAYLOAD:mf.dll ignored; no imports found from mf.dll

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp (267035 => 267036)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp	2020-09-14 20:31:34 UTC (rev 267036)
@@ -56,7 +56,7 @@
     if (AudioDestinationCocoa::createOverride)
         return AudioDestinationCocoa::createOverride(callback, sampleRate);
 
-    auto destination = makeUnique<AudioDestinationCocoa>(callback, sampleRate);
+    auto destination = makeUnique<AudioDestinationCocoa>(callback, numberOfOutputChannels, sampleRate);
     destination->configure();
     return destination;
 }
@@ -71,15 +71,12 @@
     return AudioSession::sharedSession().maximumNumberOfOutputChannels();
 }
 
-// FIXME: We should not be hardcoding the number of input channels.
-constexpr unsigned legacyNumberOfOutputChannels { 2 };
-
-AudioDestinationCocoa::AudioDestinationCocoa(AudioIOCallback& callback, float sampleRate)
+AudioDestinationCocoa::AudioDestinationCocoa(AudioIOCallback& callback, unsigned numberOfOutputChannels, float sampleRate)
     : m_outputUnit(0)
     , m_callback(callback)
-    , m_outputBus(AudioBus::create(legacyNumberOfOutputChannels, kRenderBufferSize, false).releaseNonNull())
-    , m_renderBus(AudioBus::create(legacyNumberOfOutputChannels, kRenderBufferSize).releaseNonNull())
-    , m_fifo(makeUniqueRef<PushPullFIFO>(legacyNumberOfOutputChannels, fifoSize))
+    , m_outputBus(AudioBus::create(numberOfOutputChannels, kRenderBufferSize, false).releaseNonNull())
+    , m_renderBus(AudioBus::create(numberOfOutputChannels, kRenderBufferSize).releaseNonNull())
+    , m_fifo(makeUniqueRef<PushPullFIFO>(numberOfOutputChannels, fifoSize))
     , m_contextSampleRate(sampleRate)
 {
     configure();
@@ -87,7 +84,7 @@
     auto hardwareSampleRate = this->hardwareSampleRate();
     if (sampleRate != hardwareSampleRate) {
         double scaleFactor = static_cast<double>(sampleRate) / hardwareSampleRate;
-        m_resampler = makeUnique<MultiChannelResampler>(scaleFactor, legacyNumberOfOutputChannels, kRenderBufferSize);
+        m_resampler = makeUnique<MultiChannelResampler>(scaleFactor, numberOfOutputChannels, kRenderBufferSize);
     }
 }
 
@@ -97,6 +94,11 @@
         AudioComponentInstanceDispose(m_outputUnit);
 }
 
+unsigned AudioDestinationCocoa::numberOfOutputChannels() const
+{
+    return m_renderBus->numberOfChannels();
+}
+
 unsigned AudioDestinationCocoa::framesPerBuffer() const
 {
     return m_renderBus->length();
@@ -139,7 +141,7 @@
     streamFormat.mBytesPerPacket = bytesPerFloat;
     streamFormat.mFramesPerPacket = 1;
     streamFormat.mBytesPerFrame = bytesPerFloat;
-    streamFormat.mChannelsPerFrame = 2;
+    streamFormat.mChannelsPerFrame = numberOfOutputChannels();
     streamFormat.mBitsPerChannel = bitsPerByte * bytesPerFloat;
 }
 

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.h (267035 => 267036)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.h	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.h	2020-09-14 20:31:34 UTC (rev 267036)
@@ -45,7 +45,7 @@
 // An AudioDestination using CoreAudio's default output AudioUnit
 class AudioDestinationCocoa : public AudioDestination, public AudioSourceProvider {
 public:
-    AudioDestinationCocoa(AudioIOCallback&, float sampleRate);
+    AudioDestinationCocoa(AudioIOCallback&, unsigned numberOfOutputChannels, float sampleRate);
     virtual ~AudioDestinationCocoa();
 
     WEBCORE_EXPORT static CreateAudioDestinationCocoaOverride createOverride;
@@ -57,6 +57,8 @@
     float sampleRate() const final { return m_contextSampleRate; }
     unsigned framesPerBuffer() const final;
     AudioUnit& outputUnit() { return m_outputUnit; }
+
+    unsigned numberOfOutputChannels() const;
     
     // DefaultOutputUnit callback
     static OSStatus inputProc(void* userData, AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32 busNumber, UInt32 numberOfFrames, AudioBufferList* ioData);

Modified: trunk/Source/WebCore/platform/mock/MockAudioDestinationCocoa.cpp (267035 => 267036)


--- trunk/Source/WebCore/platform/mock/MockAudioDestinationCocoa.cpp	2020-09-14 20:22:20 UTC (rev 267035)
+++ trunk/Source/WebCore/platform/mock/MockAudioDestinationCocoa.cpp	2020-09-14 20:31:34 UTC (rev 267036)
@@ -37,7 +37,7 @@
 const int kRenderBufferSize = 128;
 
 MockAudioDestinationCocoa::MockAudioDestinationCocoa(AudioIOCallback& callback, float sampleRate)
-    : AudioDestinationCocoa(callback, sampleRate)
+    : AudioDestinationCocoa(callback, 2, sampleRate)
     , m_workQueue(WorkQueue::create("MockAudioDestinationCocoa Render Queue"))
     , m_timer(RunLoop::current(), this, &MockAudioDestinationCocoa::tick)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to