Title: [266559] trunk
Revision
266559
Author
cdu...@apple.com
Date
2020-09-03 14:43:41 -0700 (Thu, 03 Sep 2020)

Log Message

AudioDestinationNode.maxChannelCount always returns 0
https://bugs.webkit.org/show_bug.cgi?id=216127

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/ctor-delay-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-destinationnode-interface/destination-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-iirfilternode-interface/ctor-iirfilter-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiodestinationnode-interface/ctor-mediastreamaudiodestination-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt:

Source/WebCore:

Update AudioDestinationNode.maxChannelCount to return a sane value on both macOS
and iOS. Also make sure the proper exceptions are thrown when trying to create
an AudioNode with an invalid number of channels.

No new tests, rebaselined existing tests.

* Modules/webaudio/AudioDestinationNode.h:
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::setChannelCount):
* Modules/webaudio/DefaultAudioDestinationNode.cpp:
(WebCore::DefaultAudioDestinationNode::setChannelCount):
* platform/audio/AudioSession.cpp:
(WebCore::AudioSession::maximumNumberOfOutputChannels const):
* platform/audio/AudioSession.h:
* platform/audio/cocoa/AudioDestinationCocoa.cpp:
(WebCore::AudioDestination::create):
(WebCore::AudioDestination::maxChannelCount):
* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::AudioSession::maximumNumberOfOutputChannels const):
* platform/audio/mac/AudioSessionMac.mm:
(WebCore::AudioSession::maximumNumberOfOutputChannels const):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-03 21:43:41 UTC (rev 266559)
@@ -1,5 +1,28 @@
 2020-09-03  Chris Dumez  <cdu...@apple.com>
 
+        AudioDestinationNode.maxChannelCount always returns 0
+        https://bugs.webkit.org/show_bug.cgi?id=216127
+
+        Reviewed by Eric Carlson.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/ctor-delay-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-destinationnode-interface/destination-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-iirfilternode-interface/ctor-iirfilter-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiodestinationnode-interface/ctor-mediastreamaudiodestination-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt:
+
+2020-09-03  Chris Dumez  <cdu...@apple.com>
+
         Make AudioParam.cancelScheduledValues() standards compliant
         https://bugs.webkit.org/show_bug.cgi?id=216132
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -33,8 +33,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new AnalyserNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new AnalyserNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new AnalyserNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new AnalyserNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new AnalyserNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new AnalyserNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new AnalyserNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -31,8 +31,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new BiquadFilterNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new BiquadFilterNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new BiquadFilterNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new BiquadFilterNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new BiquadFilterNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new BiquadFilterNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new BiquadFilterNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -32,7 +32,7 @@
 PASS   node.channelCount is equal to 1. 
 PASS   new ConvolverNode(c, {"channelCount":2}) did not throw an exception. 
 PASS   node.channelCount is equal to 2. 
-PASS   new ConvolverNode(c, {"channelCount":0}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new ConvolverNode(c, {"channelCount":0}) threw NotSupportedError: "Channel count cannot be 0". 
 PASS   new ConvolverNode(c, {"channelCount":3}) threw NotSupportedError: "ConvolverNode's channel count cannot be greater than 2". 
 PASS   new ConvolverNode(c, {"channelCount":99}) threw NotSupportedError: "ConvolverNode's channel count cannot be greater than 2". 
 PASS   new ConvolverNode(c, {"channelCountMode":"clamped-max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/ctor-delay-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/ctor-delay-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/ctor-delay-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -27,8 +27,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new DelayNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new DelayNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new DelayNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new DelayNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new DelayNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new DelayNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new DelayNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-destinationnode-interface/destination-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-destinationnode-interface/destination-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-destinationnode-interface/destination-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -1,5 +1,5 @@
 
-FAIL 
+PASS 
       AudioDestinationNode
-     assert_greater_than_equal: maxChannelCount should be >= 2 expected a number greater than or equal to 2 but got 0
+     
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -34,7 +34,7 @@
 PASS   node.channelCount is equal to 1. 
 PASS   new DynamicsCompressorNode(c, {"channelCount":2}) did not throw an exception. 
 PASS   node.channelCount is equal to 2. 
-PASS   new DynamicsCompressorNode(c, {"channelCount":0}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new DynamicsCompressorNode(c, {"channelCount":0}) threw NotSupportedError: "Channel count cannot be 0". 
 PASS   new DynamicsCompressorNode(c, {"channelCount":3}) threw NotSupportedError: "DynamicsCompressorNode's channel count cannot be greater than 2". 
 PASS   new DynamicsCompressorNode(c, {"channelCount":99}) threw NotSupportedError: "DynamicsCompressorNode's channel count cannot be greater than 2". 
 PASS   new DynamicsCompressorNode(c, {"channelCountMode":"clamped-max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -27,8 +27,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new GainNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new GainNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new GainNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new GainNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new GainNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new GainNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new GainNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-iirfilternode-interface/ctor-iirfilter-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-iirfilternode-interface/ctor-iirfilter-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-iirfilternode-interface/ctor-iirfilter-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -27,8 +27,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new IIRFilterNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new IIRFilterNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new IIRFilterNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new IIRFilterNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new IIRFilterNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new IIRFilterNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new IIRFilterNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiodestinationnode-interface/ctor-mediastreamaudiodestination-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiodestinationnode-interface/ctor-mediastreamaudiodestination-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiodestinationnode-interface/ctor-mediastreamaudiodestination-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -25,8 +25,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new MediaStreamAudioDestinationNode(c, {channelCount: 7}) did not throw an exception. 
 PASS   node.channelCount is equal to 7. 
-PASS   new MediaStreamAudioDestinationNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new MediaStreamAudioDestinationNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new MediaStreamAudioDestinationNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new MediaStreamAudioDestinationNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new MediaStreamAudioDestinationNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new MediaStreamAudioDestinationNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -28,8 +28,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new OscillatorNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new OscillatorNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new OscillatorNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new OscillatorNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new OscillatorNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new OscillatorNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new OscillatorNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -51,8 +51,8 @@
 PASS   node1.channelCount is equal to 1. 
 PASS   node2 = new PannerNode(c, {"channelCount":2}) did not throw an exception. 
 PASS   node2.channelCount is equal to 2. 
-PASS   new PannerNode(c, {"channelCount":0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   node.channelCount = 0 threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new PannerNode(c, {"channelCount":0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   node.channelCount = 0 threw NotSupportedError: "Channel count cannot be 0". 
 PASS   node.channelCount after setting to 0 is equal to 2. 
 PASS   new PannerNode(c, {"channelCount":3}) threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2". 
 PASS   node.channelCount = 3 threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2". 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -29,7 +29,7 @@
 PASS   node.channelCount is equal to 1. 
 PASS   new StereoPannerNode(c, {"channelCount":2}) did not throw an exception. 
 PASS   node.channelCount is equal to 2. 
-PASS   new StereoPannerNode(c, {"channelCount":0}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new StereoPannerNode(c, {"channelCount":0}) threw NotSupportedError: "Channel count cannot be 0". 
 PASS   new StereoPannerNode(c, {"channelCount":3}) threw NotSupportedError: "StereoPannerNode's channelCount cannot be greater than 2.". 
 PASS   new StereoPannerNode(c, {"channelCount":99}) threw NotSupportedError: "StereoPannerNode's channelCount cannot be greater than 2.". 
 PASS   new StereoPannerNode(c, {"channelCountMode":"clamped-max"}) did not throw an exception. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt (266558 => 266559)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt	2020-09-03 21:43:41 UTC (rev 266559)
@@ -28,8 +28,8 @@
 PASS > [test AudioNodeOptions]  
 PASS   new WaveShaperNode(c, {channelCount: 17}) did not throw an exception. 
 PASS   node.channelCount is equal to 17. 
-PASS   new WaveShaperNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
-PASS   new WaveShaperNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new WaveShaperNode(c, {channelCount: 0}) threw NotSupportedError: "Channel count cannot be 0". 
+PASS   new WaveShaperNode(c, {channelCount: 99}) threw IndexSizeError: "Channel count exceeds maximum limit". 
 PASS   new WaveShaperNode(c, {channelCountMode: "max"} did not throw an exception. 
 PASS   node.channelCountMode is equal to max. 
 PASS   new WaveShaperNode(c, {channelCountMode: "max"}) did not throw an exception. 

Modified: trunk/Source/WebCore/ChangeLog (266558 => 266559)


--- trunk/Source/WebCore/ChangeLog	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/ChangeLog	2020-09-03 21:43:41 UTC (rev 266559)
@@ -1,5 +1,34 @@
 2020-09-03  Chris Dumez  <cdu...@apple.com>
 
+        AudioDestinationNode.maxChannelCount always returns 0
+        https://bugs.webkit.org/show_bug.cgi?id=216127
+
+        Reviewed by Eric Carlson.
+
+        Update AudioDestinationNode.maxChannelCount to return a sane value on both macOS
+        and iOS. Also make sure the proper exceptions are thrown when trying to create
+        an AudioNode with an invalid number of channels.
+
+        No new tests, rebaselined existing tests.
+
+        * Modules/webaudio/AudioDestinationNode.h:
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::setChannelCount):
+        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
+        (WebCore::DefaultAudioDestinationNode::setChannelCount):
+        * platform/audio/AudioSession.cpp:
+        (WebCore::AudioSession::maximumNumberOfOutputChannels const):
+        * platform/audio/AudioSession.h:
+        * platform/audio/cocoa/AudioDestinationCocoa.cpp:
+        (WebCore::AudioDestination::create):
+        (WebCore::AudioDestination::maxChannelCount):
+        * platform/audio/ios/AudioSessionIOS.mm:
+        (WebCore::AudioSession::maximumNumberOfOutputChannels const):
+        * platform/audio/mac/AudioSessionMac.mm:
+        (WebCore::AudioSession::maximumNumberOfOutputChannels const):
+
+2020-09-03  Chris Dumez  <cdu...@apple.com>
+
         Make AudioParam.cancelScheduledValues() standards compliant
         https://bugs.webkit.org/show_bug.cgi?id=216132
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.h (266558 => 266559)


--- trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.h	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.h	2020-09-03 21:43:41 UTC (rev 266559)
@@ -49,7 +49,7 @@
     size_t currentSampleFrame() const { return m_currentSampleFrame; }
     double currentTime() const { return currentSampleFrame() / static_cast<double>(sampleRate()); }
 
-    virtual unsigned maxChannelCount() const { return 0; }
+    virtual unsigned maxChannelCount() const = 0;
 
     // Enable local/live input for the specified device.
     virtual void enableInput(const String& inputDeviceId) = 0;

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (266558 => 266559)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-09-03 21:43:41 UTC (rev 266559)
@@ -387,9 +387,12 @@
     BaseAudioContext::AutoLocker locker(context());
 
     ALWAYS_LOG(LOGIDENTIFIER, channelCount);
+
+    if (!channelCount)
+        return Exception { NotSupportedError, "Channel count cannot be 0"_s };
     
-    if (!(channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()))
-        return Exception { InvalidStateError };
+    if (channelCount > AudioContext::maxNumberOfChannels())
+        return Exception { IndexSizeError, "Channel count exceeds maximum limit"_s };
 
     if (m_channelCount == channelCount)
         return { };

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp (266558 => 266559)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-09-03 21:43:41 UTC (rev 266559)
@@ -153,8 +153,8 @@
     ASSERT(isMainThread());
     ALWAYS_LOG(LOGIDENTIFIER, channelCount);
 
-    if (!maxChannelCount() || channelCount > maxChannelCount())
-        return Exception { InvalidStateError };
+    if (channelCount > maxChannelCount())
+        return Exception { IndexSizeError, "Channel count exceeds maximum limit"_s };
 
     auto oldChannelCount = this->channelCount();
     auto result = AudioNode::setChannelCount(channelCount);

Modified: trunk/Source/WebCore/platform/audio/AudioSession.cpp (266558 => 266559)


--- trunk/Source/WebCore/platform/audio/AudioSession.cpp	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/platform/audio/AudioSession.cpp	2020-09-03 21:43:41 UTC (rev 266559)
@@ -134,6 +134,12 @@
     return 0;
 }
 
+size_t AudioSession::maximumNumberOfOutputChannels() const
+{
+    notImplemented();
+    return 0;
+}
+
 bool AudioSession::tryToSetActiveInternal(bool)
 {
     notImplemented();

Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (266558 => 266559)


--- trunk/Source/WebCore/platform/audio/AudioSession.h	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h	2020-09-03 21:43:41 UTC (rev 266559)
@@ -81,6 +81,7 @@
     virtual float sampleRate() const;
     virtual size_t bufferSize() const;
     virtual size_t numberOfOutputChannels() const;
+    virtual size_t maximumNumberOfOutputChannels() const;
 
     bool tryToSetActive(bool);
 

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


--- trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp	2020-09-03 21:43:41 UTC (rev 266559)
@@ -47,8 +47,7 @@
     if (numberOfInputChannels)
         WTFLogAlways("AudioDestination::create(%u, %u, %f) - unhandled input channels", numberOfInputChannels, numberOfOutputChannels, sampleRate);
 
-    // FIXME: Add support for multi-channel (> stereo) output.
-    if (numberOfOutputChannels != 2)
+    if (numberOfOutputChannels > AudioSession::sharedSession().maximumNumberOfOutputChannels())
         WTFLogAlways("AudioDestination::create(%u, %u, %f) - unhandled output channels", numberOfInputChannels, numberOfOutputChannels, sampleRate);
 
     if (AudioDestinationCocoa::createOverride)
@@ -66,10 +65,7 @@
 
 unsigned long AudioDestination::maxChannelCount()
 {
-    // FIXME: query the default audio hardware device to return the actual number
-    // of channels of the device. Also see corresponding FIXME in create().
-    // There is a small amount of code which assumes stereo which can be upgraded.
-    return 0;
+    return AudioSession::sharedSession().maximumNumberOfOutputChannels();
 }
 
 AudioDestinationCocoa::AudioDestinationCocoa(AudioIOCallback& callback, float sampleRate)

Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm (266558 => 266559)


--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2020-09-03 21:43:41 UTC (rev 266559)
@@ -254,6 +254,11 @@
     return [[PAL::getAVAudioSessionClass() sharedInstance] outputNumberOfChannels];
 }
 
+size_t AudioSession::maximumNumberOfOutputChannels() const
+{
+    return [[PAL::getAVAudioSessionClass() sharedInstance] maximumOutputNumberOfChannels];
+}
+
 bool AudioSession::tryToSetActiveInternal(bool active)
 {
     __block NSError* error = nil;

Modified: trunk/Source/WebCore/platform/audio/mac/AudioSessionMac.mm (266558 => 266559)


--- trunk/Source/WebCore/platform/audio/mac/AudioSessionMac.mm	2020-09-03 21:42:44 UTC (rev 266558)
+++ trunk/Source/WebCore/platform/audio/mac/AudioSessionMac.mm	2020-09-03 21:43:41 UTC (rev 266559)
@@ -33,6 +33,7 @@
 #import "NotImplemented.h"
 #import <CoreAudio/AudioHardware.h>
 #import <wtf/MainThread.h>
+#import <wtf/UniqueArray.h>
 #import <wtf/text/WTFString.h>
 
 #import <pal/cocoa/AVFoundationSoftLink.h>
@@ -222,6 +223,32 @@
     return 0;
 }
 
+size_t AudioSession::maximumNumberOfOutputChannels() const
+{
+    AudioObjectPropertyAddress sizeAddress = {
+        kAudioDevicePropertyStreamConfiguration,
+        kAudioObjectPropertyScopeOutput,
+        kAudioObjectPropertyElementMaster
+    };
+
+    UInt32 size = 0;
+    OSStatus result = AudioObjectGetPropertyDataSize(defaultDevice(), &sizeAddress, 0, 0, &size);
+    if (result || !size)
+        return 0;
+
+    auto listMemory = makeUniqueArray<uint8_t>(size);
+    auto* audioBufferList = reinterpret_cast<AudioBufferList*>(listMemory.get());
+
+    result = AudioObjectGetPropertyData(defaultDevice(), &sizeAddress, 0, 0, &size, audioBufferList);
+    if (result)
+        return 0;
+
+    size_t channels = 0;
+    for (UInt32 i = 0; i < audioBufferList->mNumberBuffers; ++i)
+        channels += audioBufferList->mBuffers[i].mNumberChannels;
+    return channels;
+}
+
 bool AudioSession::tryToSetActiveInternal(bool)
 {
     notImplemented();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to