⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 264176 in webkit


Ignore:
Timestamp:
Jul 9, 2020, 9:31:33 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Set Restrictions for channelCount, channelCountMode for PannerNode
​https://bugs.webkit.org/show_bug.cgi?id=213992

Patch by Clark Wang <​clark_wang@apple.com> on 2020-07-09
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Re-baselined tests that now pass.

  • web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt:

Source/WebCore:

Added setter methods to PannerNode that handle exceptions for channelCount, channelCountMode, according to spec:
​https://www.w3.org/TR/webaudio/#dom-audionode-channelcount.
Moved ChannelCount, ChannelCountMode enums into their own files.

Re-baselined tests that now pass.

  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/webaudio/AudioNode.cpp:

(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::setChannelCount):
(WebCore::AudioNode::setChannelCountMode):
(WebCore::AudioNode::setChannelInterpretation):
(WebCore::AudioNode::channelCount): Deleted.
(WebCore::AudioNode::channelCountMode): Deleted.
(WebCore::AudioNode::channelInterpretation): Deleted.

  • Modules/webaudio/AudioNode.h:

(WebCore::AudioNode::channelCount const):
(WebCore::AudioNode::channelCountMode const):
(WebCore::AudioNode::channelInterpretation const):
(WebCore::AudioNode::internalChannelCountMode const): Deleted.
(WebCore::AudioNode::internalChannelInterpretation const): Deleted.

  • Modules/webaudio/AudioNode.idl:
  • Modules/webaudio/AudioNodeInput.cpp:

(WebCore::AudioNodeInput::numberOfChannels const):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):

  • Modules/webaudio/AudioNodeOptions.h:
  • Modules/webaudio/AudioNodeOptions.idl:
  • Modules/webaudio/ChannelCountMode.h: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.h.
  • Modules/webaudio/ChannelCountMode.idl: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.idl.
  • Modules/webaudio/ChannelInterpretation.h: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.h.
  • Modules/webaudio/ChannelInterpretation.idl: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.idl.
  • Modules/webaudio/ConvolverNode.cpp:

(WebCore::ConvolverNode::ConvolverNode):

  • Modules/webaudio/DefaultAudioDestinationNode.cpp:

(WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):

  • Modules/webaudio/PannerNode.cpp:

(WebCore::PannerNode::PannerNode):
(WebCore::PannerNode::create):
(WebCore::PannerNode::setChannelCount):
(WebCore::PannerNode::setChannelCountMode):

  • Modules/webaudio/PannerNode.h:
  • Modules/webaudio/WebKitAudioPannerNode.cpp:

(WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/audio/AudioBus.cpp:

(WebCore::AudioBus::copyFrom):
(WebCore::AudioBus::sumFrom):

  • platform/audio/AudioBus.h:
Location:
trunk
Files:
22 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r264174 r264176  
     12020-07-09  Clark Wang  <clark_wang@apple.com>
     2
     3        Set Restrictions for channelCount, channelCountMode for PannerNode
     4        https://bugs.webkit.org/show_bug.cgi?id=213992
     5
     6        Reviewed by Chris Dumez.
     7
     8        Re-baselined tests that now pass.
     9
     10        * web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt:
     11
    1122020-07-09  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner-expected.txt

    r263985 r264176  
    4545PASS   node.channelCount = 0 threw InvalidStateError: "The object is in an invalid state.".
    4646PASS   node.channelCount after setting to 0 is equal to 2.
    47 FAIL X new PannerNode(c, {"channelCount":3}) did not throw an exception. assert_true: expected true got false
    48 FAIL X node.channelCount = 3 did not throw an exception. assert_true: expected true got false
    49 FAIL X node.channelCount after setting to 3 is not equal to 2. Got 3. assert_true: expected true got false
    50 PASS   new PannerNode(c, {"channelCount":99}) threw InvalidStateError: "The object is in an invalid state.".
    51 PASS   node.channelCount = 99 threw InvalidStateError: "The object is in an invalid state.".
     47PASS   new PannerNode(c, {"channelCount":3}) threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2".
     48PASS   node.channelCount = 3 threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2".
     49PASS   node.channelCount after setting to 3 is equal to 2.
     50PASS   new PannerNode(c, {"channelCount":99}) threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2".
     51PASS   node.channelCount = 99 threw NotSupportedError: "PannerNode's channelCount cannot be greater than 2".
    5252PASS   node.channelCount after setting to 99 is equal to 2.
    5353PASS   node3 = new PannerNode(c, {"channelCountMode":"clamped-max"}) did not throw an exception.
    … …  
    5555PASS   node4 = new PannerNode(c, {"channelCountMode":"explicit"}) did not throw an exception.
    5656PASS   node4.channelCountMode is equal to explicit.
    57 FAIL X new PannerNode(c, {"channelCountMode":"max"}) did not throw an exception. assert_true: expected true got false
    58 FAIL X node.channelCountMode = max did not throw an exception. assert_true: expected true got false
    59 FAIL X node.channelCountMode after setting to max is not equal to clamped-max. Got max. assert_true: expected true got false
    60 FAIL X new PannerNode(c, " + JSON.stringify(options) + ") threw "InvalidStateError" instead of EcmaScript error TypeError. assert_true: expected true got false
    61 FAIL X node.channelCountMode = foobar incorrectly threw InvalidStateError: "The object is in an invalid state.". assert_true: expected true got false
     57PASS   new PannerNode(c, {"channelCountMode":"max"}) threw NotSupportedError: "PannerNode's channelCountMode cannot be max".
     58PASS   node.channelCountMode = max threw NotSupportedError: "PannerNode's channelCountMode cannot be max".
     59PASS   node.channelCountMode after setting to max is equal to clamped-max.
     60PASS   new PannerNode(c, " + JSON.stringify(options) + ") threw TypeError: "Type error".
     61PASS   node.channelCountMode = foobar did not throw an exception.
    6262PASS   node.channelCountMode after setting to foobar is equal to clamped-max.
    6363PASS   node5 = new PannerNode(c, {"channelInterpretation":"speakers"}) did not throw an exception.
    … …  
    6565PASS   node6 = new PannerNode(c, {"channelInterpretation":"discrete"}) did not throw an exception.
    6666PASS   node6.channelInterpretation is equal to discrete.
    67 FAIL X new PannerNode(c, {"channelInterpretation":"foobar"}) threw "InvalidStateError" instead of EcmaScript error TypeError. assert_true: expected true got false
     67PASS   new PannerNode(c, {"channelInterpretation":"foobar"}) threw TypeError: "Type error".
    6868PASS   new PannerNode(c, {"maxDistance":-1}) threw RangeError: "maxDistance cannot be set to a non-positive value".
    6969PASS   node.maxDistance = -1 threw RangeError: "maxDistance cannot be set to a non-positive value".
    … …  
    9292PASS   node9 = new PannerNode(c, {"coneOuterGain":1}) did not throw an exception.
    9393PASS   node9.coneOuterGain is equal to 1.
    94 FAIL < [test AudioNodeOptions] 9 out of 54 assertions were failed. assert_true: expected true got false
     94PASS < [test AudioNodeOptions] All assertions passed. (total 54 assertions)
    9595PASS > [constructor with options] 
    9696PASS   node = new PannerNode(c, {"panningModel":"HRTF","positionX":1.4142135623730951,"positionY":2.8284271247461903,"positionZ":4.242640687119286,"orientationX":-1.4142135623730951,"orientationY":-2.8284271247461903,"orientationZ":-4.242640687119286,"distanceModel":"linear","refDistance":3.141592653589793,"maxDistance":6.283185307179586,"rolloffFactor":9.42477796076938,"coneInnerAngle":12.566370614359172,"coneOuterAngle":15.707963267948966,"coneOuterGain":0.3141592653589793}) did not throw an exception.
    … …  
    114114PASS   node.channelInterpretation is equal to speakers.
    115115PASS < [constructor with options] All assertions passed. (total 19 assertions)
    116 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 5 tasks were failed. assert_true: expected true got false
     116PASS # AUDIT TASK RUNNER FINISHED: 5 tasks ran successfully.
    117117
  • trunk/Source/WebCore/CMakeLists.txt

    r263985 r264176  
    460460    Modules/webaudio/BaseAudioContext.idl
    461461    Modules/webaudio/BiquadFilterNode.idl
     462    Modules/webaudio/ChannelCountMode.idl
     463    Modules/webaudio/ChannelInterpretation.idl
    462464    Modules/webaudio/ChannelMergerNode.idl
    463465    Modules/webaudio/ChannelSplitterNode.idl
  • trunk/Source/WebCore/ChangeLog

    r264175 r264176  
     12020-07-09  Clark Wang  <clark_wang@apple.com>
     2
     3        Set Restrictions for channelCount, channelCountMode for PannerNode
     4        https://bugs.webkit.org/show_bug.cgi?id=213992
     5
     6        Reviewed by Chris Dumez.
     7
     8        Added setter methods to PannerNode that handle exceptions for channelCount, channelCountMode, according to spec:
     9        https://www.w3.org/TR/webaudio/#dom-audionode-channelcount.
     10        Moved ChannelCount, ChannelCountMode enums into their own files.
     11
     12        Re-baselined tests that now pass.
     13
     14        * CMakeLists.txt:
     15        * DerivedSources-input.xcfilelist:
     16        * DerivedSources-output.xcfilelist:
     17        * DerivedSources.make:
     18        * Modules/webaudio/AudioNode.cpp:
     19        (WebCore::AudioNode::AudioNode):
     20        (WebCore::AudioNode::setChannelCount):
     21        (WebCore::AudioNode::setChannelCountMode):
     22        (WebCore::AudioNode::setChannelInterpretation):
     23        (WebCore::AudioNode::channelCount): Deleted.
     24        (WebCore::AudioNode::channelCountMode): Deleted.
     25        (WebCore::AudioNode::channelInterpretation): Deleted.
     26        * Modules/webaudio/AudioNode.h:
     27        (WebCore::AudioNode::channelCount const):
     28        (WebCore::AudioNode::channelCountMode const):
     29        (WebCore::AudioNode::channelInterpretation const):
     30        (WebCore::AudioNode::internalChannelCountMode const): Deleted.
     31        (WebCore::AudioNode::internalChannelInterpretation const): Deleted.
     32        * Modules/webaudio/AudioNode.idl:
     33        * Modules/webaudio/AudioNodeInput.cpp:
     34        (WebCore::AudioNodeInput::numberOfChannels const):
     35        (WebCore::AudioNodeInput::bus):
     36        (WebCore::AudioNodeInput::sumAllConnections):
     37        (WebCore::AudioNodeInput::pull):
     38        * Modules/webaudio/AudioNodeOptions.h:
     39        * Modules/webaudio/AudioNodeOptions.idl:
     40        * Modules/webaudio/ChannelCountMode.h: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.h.
     41        * Modules/webaudio/ChannelCountMode.idl: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.idl.
     42        * Modules/webaudio/ChannelInterpretation.h: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.h.
     43        * Modules/webaudio/ChannelInterpretation.idl: Copied from Source/WebCore/Modules/webaudio/AudioNodeOptions.idl.
     44        * Modules/webaudio/ConvolverNode.cpp:
     45        (WebCore::ConvolverNode::ConvolverNode):
     46        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
     47        (WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):
     48        * Modules/webaudio/PannerNode.cpp:
     49        (WebCore::PannerNode::PannerNode):
     50        (WebCore::PannerNode::create):
     51        (WebCore::PannerNode::setChannelCount):
     52        (WebCore::PannerNode::setChannelCountMode):
     53        * Modules/webaudio/PannerNode.h:
     54        * Modules/webaudio/WebKitAudioPannerNode.cpp:
     55        (WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):
     56        * Sources.txt:
     57        * WebCore.xcodeproj/project.pbxproj:
     58        * platform/audio/AudioBus.cpp:
     59        (WebCore::AudioBus::copyFrom):
     60        (WebCore::AudioBus::sumFrom):
     61        * platform/audio/AudioBus.h:
     62
    1632020-07-09  Alicia Boya García  <aboya@igalia.com>
    264
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r263985 r264176  
    309309$(PROJECT_DIR)/Modules/webaudio/BaseAudioContext.idl
    310310$(PROJECT_DIR)/Modules/webaudio/BiquadFilterNode.idl
     311$(PROJECT_DIR)/Modules/webaudio/ChannelCountMode.idl
     312$(PROJECT_DIR)/Modules/webaudio/ChannelInterpretation.idl
    311313$(PROJECT_DIR)/Modules/webaudio/ChannelMergerNode.idl
    312314$(PROJECT_DIR)/Modules/webaudio/ChannelSplitterNode.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r263985 r264176  
    302302$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasUserInterface.cpp
    303303$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasUserInterface.h
     304$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelCountMode.cpp
     305$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelCountMode.h
     306$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelInterpretation.cpp
     307$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelInterpretation.h
    304308$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelMergerNode.cpp
    305309$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSChannelMergerNode.h
  • trunk/Source/WebCore/DerivedSources.make

    r263985 r264176  
    392392    $(WebCore)/Modules/webaudio/BaseAudioContext.idl \
    393393    $(WebCore)/Modules/webaudio/BiquadFilterNode.idl \
     394    $(WebCore)/Modules/webaudio/ChannelCountMode.idl \
     395    $(WebCore)/Modules/webaudio/ChannelInterpretation.idl \
    394396    $(WebCore)/Modules/webaudio/ChannelMergerNode.idl \
    395397    $(WebCore)/Modules/webaudio/ChannelSplitterNode.idl \
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp

    r263985 r264176  
    107107#endif
    108108    , m_channelCount(2)
    109     , m_channelCountMode(Max)
    110     , m_channelInterpretation(AudioBus::Speakers)
     109    , m_channelCountMode(ChannelCountMode::Max)
     110    , m_channelInterpretation(ChannelInterpretation::Speakers)
    111111{
    112112    ALWAYS_LOG(LOGIDENTIFIER);
    … …  
    269269}
    270270
    271 unsigned AudioNode::channelCount()
    272 {
    273     return m_channelCount;
    274 }
    275 
    276271ExceptionOr<void> AudioNode::setChannelCount(unsigned channelCount)
    277272{
    … …  
    288283
    289284    m_channelCount = channelCount;
    290     if (m_channelCountMode != Max)
     285    if (m_channelCountMode != ChannelCountMode::Max)
    291286        updateChannelsForInputs();
    292287    return { };
    293288}
    294289
    295 String AudioNode::channelCountMode()
    296 {
    297     switch (m_channelCountMode) {
    298     case Max:
    299         return "max"_s;
    300     case ClampedMax:
    301         return "clamped-max"_s;
    302     case Explicit:
    303         return "explicit"_s;
    304     }
    305     ASSERT_NOT_REACHED();
    306     return emptyString();
    307 }
    308 
    309 ExceptionOr<void> AudioNode::setChannelCountMode(const String& mode)
     290ExceptionOr<void> AudioNode::setChannelCountMode(ChannelCountMode mode)
    310291{
    311292    ASSERT(isMainThread());
    … …  
    315296   
    316297    ChannelCountMode oldMode = m_channelCountMode;
    317 
    318     if (mode == "max")
    319         m_channelCountMode = Max;
    320     else if (mode == "clamped-max")
    321         m_channelCountMode = ClampedMax;
    322     else if (mode == "explicit")
    323         m_channelCountMode = Explicit;
    324     else
    325         return Exception { InvalidStateError };
     298    m_channelCountMode = mode;
    326299
    327300    if (m_channelCountMode != oldMode)
    … …  
    331304}
    332305
    333 String AudioNode::channelInterpretation()
    334 {
    335     switch (m_channelInterpretation) {
    336     case AudioBus::Speakers:
    337         return "speakers"_s;
    338     case AudioBus::Discrete:
    339         return "discrete"_s;
    340     }
    341     ASSERT_NOT_REACHED();
    342     return emptyString();
    343 }
    344 
    345 ExceptionOr<void> AudioNode::setChannelInterpretation(const String& interpretation)
     306ExceptionOr<void> AudioNode::setChannelInterpretation(ChannelInterpretation interpretation)
    346307{
    347308    ASSERT(isMainThread());
    … …  
    350311    ALWAYS_LOG(LOGIDENTIFIER, interpretation);
    351312   
    352     if (interpretation == "speakers")
    353         m_channelInterpretation = AudioBus::Speakers;
    354     else if (interpretation == "discrete")
    355         m_channelInterpretation = AudioBus::Discrete;
    356     else
    357         return Exception { InvalidStateError };
     313    m_channelInterpretation = interpretation;
    358314
    359315    return { };
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.h

    r263985 r264176  
    2626
    2727#include "AudioBus.h"
     28#include "ChannelCountMode.h"
     29#include "ChannelInterpretation.h"
    2830#include "EventTarget.h"
    2931#include "ExceptionOr.h"
    … …  
    9395    };
    9496
    95     enum ChannelCountMode {
    96         Max,
    97         ClampedMax,
    98         Explicit
    99     };
    100 
    10197    NodeType nodeType() const { return m_nodeType; }
    10298    void setNodeType(NodeType);
    … …  
    178174    void disableOutputsIfNecessary();
    179175
    180     unsigned channelCount();
     176    unsigned channelCount() const { return m_channelCount; }
    181177    virtual ExceptionOr<void> setChannelCount(unsigned);
    182178
    183     String channelCountMode();
    184     ExceptionOr<void> setChannelCountMode(const String&);
    185 
    186     String channelInterpretation();
    187     ExceptionOr<void> setChannelInterpretation(const String&);
    188 
    189     ChannelCountMode internalChannelCountMode() const { return m_channelCountMode; }
    190     AudioBus::ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; }
     179    ChannelCountMode channelCountMode() const { return m_channelCountMode; }
     180    virtual ExceptionOr<void> setChannelCountMode(ChannelCountMode);
     181
     182    ChannelInterpretation channelInterpretation() const { return m_channelInterpretation; }
     183    ExceptionOr<void> setChannelInterpretation(ChannelInterpretation);
    191184
    192185protected:
    … …  
    252245    unsigned m_channelCount;
    253246    ChannelCountMode m_channelCountMode;
    254     AudioBus::ChannelInterpretation m_channelInterpretation;
     247    ChannelInterpretation m_channelInterpretation;
    255248};
    256249
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.idl

    r263381 r264176  
    3131
    3232    attribute unsigned long channelCount;
    33     attribute DOMString channelCountMode;
    34     attribute DOMString channelInterpretation;
     33    attribute ChannelCountMode channelCountMode;
     34    attribute ChannelInterpretation channelInterpretation;
    3535
    3636    [MayThrowException] AudioNode connect([ReturnValue] AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeInput.cpp

    r196603 r264176  
    3232#include "AudioNode.h"
    3333#include "AudioNodeOutput.h"
     34#include "ChannelCountMode.h"
    3435#include <algorithm>
    3536
    … …  
    145146unsigned AudioNodeInput::numberOfChannels() const
    146147{
    147     AudioNode::ChannelCountMode mode = node()->internalChannelCountMode();
    148     if (mode == AudioNode::Explicit)
     148    auto mode = node()->channelCountMode();
     149    if (mode == ChannelCountMode::Explicit)
    149150        return node()->channelCount();
    150151
    … …  
    158159    }
    159160
    160     if (mode == AudioNode::ClampedMax)
     161    if (mode == ChannelCountMode::ClampedMax)
    161162        maxChannels = std::min(maxChannels, static_cast<unsigned>(node()->channelCount()));
    162163
    … …  
    169170
    170171    // Handle single connection specially to allow for in-place processing.
    171     if (numberOfRenderingConnections() == 1 && node()->internalChannelCountMode() == AudioNode::Max)
     172    if (numberOfRenderingConnections() == 1 && node()->channelCountMode() == ChannelCountMode::Max)
    172173        return renderingOutput(0)->bus();
    173174
    … …  
    188189
    189190    // We shouldn't be calling this method if there's only one connection, since it's less efficient.
    190     ASSERT(numberOfRenderingConnections() > 1 || node()->internalChannelCountMode() != AudioNode::Max);
     191    ASSERT(numberOfRenderingConnections() > 1 || node()->channelCountMode() != ChannelCountMode::Max);
    191192
    192193    ASSERT(summingBus);
    … …  
    196197    summingBus->zero();
    197198
    198     AudioBus::ChannelInterpretation interpretation = node()->internalChannelInterpretation();
     199    auto interpretation = node()->channelInterpretation();
    199200
    200201    for (auto& output : m_renderingOutputs) {
    … …  
    214215
    215216    // Handle single connection case.
    216     if (numberOfRenderingConnections() == 1 && node()->internalChannelCountMode() == AudioNode::Max) {
     217    if (numberOfRenderingConnections() == 1 && node()->channelCountMode() == ChannelCountMode::Max) {
    217218        // The output will optimize processing using inPlaceBus if it's able.
    218219        AudioNodeOutput* output = this->renderingOutput(0);
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeOptions.h

    r263985 r264176  
    2828#if ENABLE(WEB_AUDIO)
    2929
     30#include "ChannelCountMode.h"
     31#include "ChannelInterpretation.h"
    3032#include <wtf/Optional.h>
    31 #include <wtf/text/WTFString.h>
    3233
    3334namespace WebCore {
    … …  
    3536struct AudioNodeOptions {
    3637    Optional<unsigned> channelCount;
    37     String channelCountMode;
    38     String channelInterpretation;
     38    Optional<ChannelCountMode> channelCountMode;
     39    Optional<ChannelInterpretation> channelInterpretation;
    3940};
    4041
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeOptions.idl

    r263985 r264176  
    2727] dictionary AudioNodeOptions {
    2828    unsigned long channelCount;
    29    
    30     // FIXME: Should be updated to use ChannelCountMode enum type.
    31     DOMString channelCountMode;
    32    
    33     // FIXME: Should be updated to use ChannelInterpretation enum type.
    34     DOMString channelInterpretation;
     29    ChannelCountMode channelCountMode;
     30    ChannelInterpretation channelInterpretation;
    3531};
  • trunk/Source/WebCore/Modules/webaudio/ChannelCountMode.h

    r264175 r264176  
    2626#pragma once
    2727
    28 #if ENABLE(WEB_AUDIO)
    29 
    30 #include <wtf/Optional.h>
    31 #include <wtf/text/WTFString.h>
    32 
    3328namespace WebCore {
    3429
    35 struct AudioNodeOptions {
    36     Optional<unsigned> channelCount;
    37     String channelCountMode;
    38     String channelInterpretation;
     30enum class ChannelCountMode {
     31    Max,
     32    ClampedMax,
     33    Explicit,
    3934};
    4035
    4136} // namespace WebCore
    42 
    43 #endif // ENABLE(WEB_AUDIO)
  • trunk/Source/WebCore/Modules/webaudio/ChannelCountMode.idl

    r264175 r264176  
    2525[
    2626    Conditional=WEB_AUDIO,
    27 ] dictionary AudioNodeOptions {
    28     unsigned long channelCount;
    29    
    30     // FIXME: Should be updated to use ChannelCountMode enum type.
    31     DOMString channelCountMode;
    32    
    33     // FIXME: Should be updated to use ChannelInterpretation enum type.
    34     DOMString channelInterpretation;
     27] enum ChannelCountMode {
     28    "max",
     29    "clamped-max",
     30    "explicit"
    3531};
  • trunk/Source/WebCore/Modules/webaudio/ChannelInterpretation.h

    r264175 r264176  
    2626#pragma once
    2727
    28 #if ENABLE(WEB_AUDIO)
    29 
    30 #include <wtf/Optional.h>
    31 #include <wtf/text/WTFString.h>
    32 
    33 namespace WebCore {
    34 
    35 struct AudioNodeOptions {
    36     Optional<unsigned> channelCount;
    37     String channelCountMode;
    38     String channelInterpretation;
    39 };
    40 
    41 } // namespace WebCore
    42 
    43 #endif // ENABLE(WEB_AUDIO)
     28#include "AudioBus.h"
  • trunk/Source/WebCore/Modules/webaudio/ChannelInterpretation.idl

    r264175 r264176  
    2525[
    2626    Conditional=WEB_AUDIO,
    27 ] dictionary AudioNodeOptions {
    28     unsigned long channelCount;
    29    
    30     // FIXME: Should be updated to use ChannelCountMode enum type.
    31     DOMString channelCountMode;
    32    
    33     // FIXME: Should be updated to use ChannelInterpretation enum type.
    34     DOMString channelInterpretation;
     27] enum ChannelInterpretation {
     28    "speakers",
     29    "discrete"
    3530};
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r263410 r264176  
    5858    // Node-specific default mixing rules.
    5959    m_channelCount = 2;
    60     m_channelCountMode = ClampedMax;
    61     m_channelInterpretation = AudioBus::Speakers;
     60    m_channelCountMode = ChannelCountMode::ClampedMax;
     61    m_channelInterpretation = ChannelInterpretation::Speakers;
    6262   
    6363    initialize();
  • trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp

    r263410 r264176  
    4949    // Node-specific default mixing rules.
    5050    m_channelCount = 2;
    51     m_channelCountMode = Explicit;
    52     m_channelInterpretation = AudioBus::Speakers;
     51    m_channelCountMode = ChannelCountMode::Explicit;
     52    m_channelInterpretation = ChannelInterpretation::Speakers;
    5353}
    5454
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp

    r263985 r264176  
    3333#include "AudioNodeInput.h"
    3434#include "AudioNodeOutput.h"
     35#include "ChannelCountMode.h"
    3536#include "HRTFDatabaseLoader.h"
    3637#include "HRTFPanner.h"
    … …  
    7677    // Node-specific default mixing rules.
    7778    m_channelCount = 2;
    78     m_channelCountMode = ClampedMax;
    79     m_channelInterpretation = AudioBus::Speakers;
     79    m_channelCountMode = ChannelCountMode::ClampedMax;
     80    m_channelInterpretation = ChannelInterpretation::Speakers;
    8081
    8182    m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0);
    … …  
    114115        return result.releaseException();
    115116   
    116     result = panner->setChannelCountMode(options.channelCountMode.isNull() ? "clamped-max"_str : options.channelCountMode);
    117     if (result.hasException())
    118         return result.releaseException();
    119    
    120     result = panner->setChannelInterpretation(options.channelInterpretation.isNull() ? "speakers"_str : options.channelInterpretation);
     117    result = panner->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::ClampedMax));
     118    if (result.hasException())
     119        return result.releaseException();
     120   
     121    result = panner->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
    121122    if (result.hasException())
    122123        return result.releaseException();
    … …  
    336337}
    337338
     339ExceptionOr<void> PannerNode::setChannelCount(unsigned channelCount)
     340{
     341    if (channelCount > 2)
     342        return Exception { NotSupportedError, "PannerNode's channelCount cannot be greater than 2"_s };
     343   
     344    return AudioNode::setChannelCount(channelCount);
     345}
     346
     347ExceptionOr<void> PannerNode::setChannelCountMode(ChannelCountMode mode)
     348{
     349    if (mode == ChannelCountMode::Max)
     350        return Exception { NotSupportedError, "PannerNode's channelCountMode cannot be max"_s };
     351   
     352    return AudioNode::setChannelCountMode(mode);
     353}
     354
    338355void PannerNode::getAzimuthElevation(double* outAzimuth, double* outElevation)
    339356{
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.h

    r263985 r264176  
    128128    double coneOuterGain() const { return m_coneEffect.outerGain(); }
    129129    ExceptionOr<void> setConeOuterGain(double);
     130   
     131    ExceptionOr<void> setChannelCount(unsigned) final;
     132    ExceptionOr<void> setChannelCountMode(ChannelCountMode) final;
    130133
    131134    void getAzimuthElevation(double* outAzimuth, double* outElevation);
  • trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp

    r263198 r264176  
    6565    // Node-specific default mixing rules.
    6666    m_channelCount = 2;
    67     m_channelCountMode = ClampedMax;
    68     m_channelInterpretation = AudioBus::Speakers;
     67    m_channelCountMode = ChannelCountMode::ClampedMax;
     68    m_channelInterpretation = ChannelInterpretation::Speakers;
    6969
    7070    m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0);
  • trunk/Source/WebCore/Sources.txt

    r263985 r264176  
    27022702JSCanvasTransform.cpp
    27032703JSCanvasUserInterface.cpp
     2704JSChannelCountMode.cpp
     2705JSChannelInterpretation.cpp
    27042706JSChannelMergerNode.cpp
    27052707JSChannelSplitterNode.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r264136 r264176  
    50465046                E71467B324ABAEF200FB2F50 /* AudioNodeOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B124ABAEF100FB2F50 /* AudioNodeOptions.h */; };
    50475047                E71467B624ABAF1D00FB2F50 /* PannerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B524ABAF1D00FB2F50 /* PannerOptions.h */; };
     5048                E785D91524B4D1CA0014DB21 /* ChannelCountMode.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D91124B4D1B10014DB21 /* ChannelCountMode.h */; };
     5049                E785D93424B636FF0014DB21 /* ChannelInterpretation.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D93124B636FF0014DB21 /* ChannelInterpretation.h */; };
    50485050                EBE5B226245A26EF003A5A88 /* SQLiteStatementAutoResetScope.h in Headers */ = {isa = PBXBuildFile; fileRef = EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
    50495051                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */; };
    … …  
    1579115793                E71467B524ABAF1D00FB2F50 /* PannerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PannerOptions.h; sourceTree = "<group>"; };
    1579215794                E71467B724ABAF2C00FB2F50 /* PannerOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PannerOptions.idl; sourceTree = "<group>"; };
     15795                E785D91124B4D1B10014DB21 /* ChannelCountMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChannelCountMode.h; sourceTree = "<group>"; };
     15796                E785D91324B4D1B10014DB21 /* ChannelCountMode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelCountMode.idl; sourceTree = "<group>"; };
     15797                E785D93124B636FF0014DB21 /* ChannelInterpretation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChannelInterpretation.h; sourceTree = "<group>"; };
     15798                E785D93324B636FF0014DB21 /* ChannelInterpretation.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelInterpretation.idl; sourceTree = "<group>"; };
    1579315799                EB081CD81696084400553730 /* TypeConversions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeConversions.h; sourceTree = "<group>"; };
    1579415800                EB081CD91696084400553730 /* TypeConversions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = TypeConversions.idl; sourceTree = "<group>"; };
    … …  
    2937129377                                FD315FDC12B0267600C1A359 /* BiquadProcessor.cpp */,
    2937229378                                FD315FDD12B0267600C1A359 /* BiquadProcessor.h */,
     29379                                E785D91124B4D1B10014DB21 /* ChannelCountMode.h */,
     29380                                E785D91324B4D1B10014DB21 /* ChannelCountMode.idl */,
     29381                                E785D93124B636FF0014DB21 /* ChannelInterpretation.h */,
     29382                                E785D93324B636FF0014DB21 /* ChannelInterpretation.idl */,
    2937329383                                FD315FB412B0267500C1A359 /* ChannelMergerNode.cpp */,
    2937429384                                FD315FB512B0267500C1A359 /* ChannelMergerNode.h */,
    … …  
    3007830088                                FE36FD1516C7826500F887C1 /* ChangeVersionData.h in Headers */,
    3007930089                                97BC69DD1505F076001B74AC /* ChangeVersionWrapper.h in Headers */,
     30090                                E785D91524B4D1CA0014DB21 /* ChannelCountMode.h in Headers */,
     30091                                E785D93424B636FF0014DB21 /* ChannelInterpretation.h in Headers */,
    3008030092                                FD315FFF12B0267600C1A359 /* ChannelMergerNode.h in Headers */,
    3008130093                                FD31600212B0267600C1A359 /* ChannelSplitterNode.h in Headers */,
  • trunk/Source/WebCore/platform/audio/AudioBus.cpp

    r248846 r264176  
    254254    } else {
    255255        switch (channelInterpretation) {
    256         case Speakers:
     256        case ChannelInterpretation::Speakers:
    257257            speakersCopyFrom(sourceBus);
    258258            break;
    259         case Discrete:
     259        case ChannelInterpretation::Discrete:
    260260            discreteCopyFrom(sourceBus);
    261261            break;
    … …  
    279279    } else {
    280280        switch (channelInterpretation) {
    281         case Speakers:
     281        case ChannelInterpretation::Speakers:
    282282            speakersSumFrom(sourceBus);
    283283            break;
    284         case Discrete:
     284        case ChannelInterpretation::Discrete:
    285285            discreteSumFrom(sourceBus);
    286286            break;
  • trunk/Source/WebCore/platform/audio/AudioBus.h

    r260415 r264176  
    4141// The data layout is "planar" as opposed to "interleaved".
    4242// An AudioBus with one channel is mono, an AudioBus with two channels is stereo, etc.
     43
     44enum class ChannelInterpretation {
     45    Speakers,
     46    Discrete,
     47};
     48
    4349class AudioBus final : public ThreadSafeRefCounted<AudioBus> {
    4450    WTF_MAKE_NONCOPYABLE(AudioBus);
    … …  
    5763        LayoutCanonical = 0
    5864        // Can define non-standard layouts here
    59     };
    60 
    61     enum ChannelInterpretation {
    62         Speakers,
    63         Discrete,
    6465    };
    6566
    … …  
    127128    // Copies the samples from the source bus to this one.
    128129    // This is just a simple per-channel copy if the number of channels match, otherwise an up-mix or down-mix is done.
    129     WEBCORE_EXPORT void copyFrom(const AudioBus& sourceBus, ChannelInterpretation = Speakers);
     130    WEBCORE_EXPORT void copyFrom(const AudioBus& sourceBus, ChannelInterpretation = ChannelInterpretation::Speakers);
    130131
    131132    // Sums the samples from the source bus to this one.
    132133    // This is just a simple per-channel summing if the number of channels match, otherwise an up-mix or down-mix is done.
    133     void sumFrom(const AudioBus& sourceBus, ChannelInterpretation = Speakers);
     134    void sumFrom(const AudioBus& sourceBus, ChannelInterpretation = ChannelInterpretation::Speakers);
    134135
    135136    // Copy each channel from sourceBus into our corresponding channel.
Note: See TracChangeset for help on using the changeset viewer.