Bug 213992 - Set Restrictions for channelCount, channelCountMode for PannerNode
Summary: Set Restrictions for channelCount, channelCountMode for PannerNode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Clark Wang
URL:
Keywords: InRadar
Depends on:
Blocks: 212611
  Show dependency treegraph
 
Reported: 2020-07-06 07:46 PDT by Clark Wang
Modified: 2020-07-09 09:32 PDT (History)
13 users (show)

See Also:


Attachments
Patch (46.09 KB, patch)
2020-07-08 12:02 PDT, Clark Wang
no flags Details | Formatted Diff | Diff
Patch (46.45 KB, patch)
2020-07-08 13:38 PDT, Clark Wang
no flags Details | Formatted Diff | Diff
Patch (46.79 KB, patch)
2020-07-08 13:47 PDT, Clark Wang
no flags Details | Formatted Diff | Diff
Patch (45.81 KB, patch)
2020-07-08 13:57 PDT, Clark Wang
no flags Details | Formatted Diff | Diff
Patch (45.48 KB, patch)
2020-07-09 07:22 PDT, Clark Wang
no flags Details | Formatted Diff | Diff
Patch (45.47 KB, patch)
2020-07-09 08:44 PDT, Clark Wang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Clark Wang 2020-07-06 07:46:53 PDT
Add setter methods to PannerNode that will handle exceptions for setting channelCount, channelCountMode. Phased out sampleRate from AudioNode, using BaseAudioContext's sampleRate instead for processIfNecessary method instead.
Comment 1 Clark Wang 2020-07-08 11:50:34 PDT
Also separated ChannelCountMode, ChannelCount enums into their own files
Comment 2 Clark Wang 2020-07-08 12:02:55 PDT
Created attachment 403800 [details]
Patch
Comment 3 Chris Dumez 2020-07-08 12:14:28 PDT
Comment on attachment 403800 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403800&action=review

> Source/WebCore/ChangeLog:8
> +        Added setter methods to PannerNode that handle exceptions for channelCount, channelCountMode, according to spec: https://www.w3.org/TR/webaudio/#dom-audionode-channelcount.

Please wrap lines properly so they are not too long like this.

> Source/WebCore/ChangeLog:9
> +        Phased out sampleRate from AudioNode, using BaseAudioContext's sampleRate for processIfNecessary method. Moved ChannelCount, ChannelCountMode enums into their own files.

Ditto.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:295
> +ChannelCountMode AudioNode::channelCountMode()

This could be inlined in the header now.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:300
> +ExceptionOr<void> AudioNode::setChannelCountMode(const ChannelCountMode mode)

const is not needed.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:309
> +    if (mode == Max)

The whole implementation of this method makes no sense anymore. Should be something like:
m_channelCountMode = mode;

> Source/WebCore/Modules/webaudio/AudioNode.cpp:324
> +ChannelInterpretation AudioNode::channelInterpretation()

This could be inlined in the header now.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:336
> +    if (interpretation == ChannelInterpretation::Speakers)

The implementation of this method does not make sense anymore.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:381
> +            m_lastNonSilentTime = (context().currentSampleFrame() + framesToProcess) / static_cast<double>(context().sampleRate());

Nothing to do with the enum string. Please split unrelated changes in separate patches.

> Source/WebCore/Modules/webaudio/AudioNode.h:180
> +    virtual ExceptionOr<void> setChannelCountMode(const ChannelCountMode);

No need for const.

> Source/WebCore/Modules/webaudio/AudioNode.h:182
> +    ChannelInterpretation channelInterpretation();

should be const.

> Source/WebCore/Modules/webaudio/AudioNode.h:185
>      ChannelCountMode internalChannelCountMode() const { return m_channelCountMode; }

This method seems identical to channelCountMode() now. It should be dropped.

> Source/WebCore/Modules/webaudio/AudioNode.h:186
> +    ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; }

ditto.

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:148
> +    ChannelCountMode mode = node()->internalChannelCountMode();

auto mode

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:161
> +    if (mode == ClampedMax)

Please make that enum an enum class.

> Source/WebCore/Modules/webaudio/AudioNodeInput.cpp:199
> +    ChannelInterpretation interpretation = node()->internalChannelInterpretation();

auto

> Source/WebCore/Modules/webaudio/ChannelCountMode.h:30
> +enum ChannelCountMode {

Should be an enum class.

> Source/WebCore/Modules/webaudio/PannerNode.cpp:342
> +        return Exception { NotSupportedError };

Please provide an explanation string...

> Source/WebCore/Modules/webaudio/PannerNode.cpp:344
> +    auto result = this->AudioNode::setChannelCount(channelCount);

this-> is not needed.

Also, seems like this could be return as:
return AudioNode::setChannelCount(channelCount);

> Source/WebCore/Modules/webaudio/PannerNode.cpp:352
> +ExceptionOr<void> PannerNode::setChannelCountMode(const ChannelCountMode mode)

No const.

> Source/WebCore/Modules/webaudio/PannerNode.cpp:357
> +    auto result = this->AudioNode::setChannelCountMode(mode);

Same comments as above.

> Source/WebCore/Modules/webaudio/PannerNode.h:131
> +    ExceptionOr<void> setChannelCount(unsigned) override;

s/override/final

> Source/WebCore/Modules/webaudio/PannerNode.h:132
> +    ExceptionOr<void> setChannelCountMode(const ChannelCountMode) override;

s/override/final
Comment 4 Clark Wang 2020-07-08 13:38:40 PDT
Created attachment 403806 [details]
Patch
Comment 5 Clark Wang 2020-07-08 13:47:09 PDT
Created attachment 403807 [details]
Patch
Comment 6 Clark Wang 2020-07-08 13:57:32 PDT
Created attachment 403808 [details]
Patch
Comment 7 Chris Dumez 2020-07-08 14:28:00 PDT
Comment on attachment 403808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403808&action=review

Patch does not build in debug.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:299
> +    if (mode != ChannelCountMode::Max && mode != ChannelCountMode::ClampedMax && mode != ChannelCountMode::Explicit)

Why not we need this check? These seem to be the only values of ChannelCountMode.

> Source/WebCore/Modules/webaudio/AudioNode.cpp:317
> +    if (interpretation != ChannelInterpretation::Speakers && interpretation != ChannelInterpretation::Discrete)

Ditto.

> Source/WebCore/Modules/webaudio/AudioNode.h:176
> +    unsigned channelCount() { return m_channelCount; }

const

> Source/WebCore/Modules/webaudio/AudioNode.h:179
> +    ChannelCountMode channelCountMode() { return m_channelCountMode; }

const
Comment 8 Chris Dumez 2020-07-08 14:28:34 PDT
Comment on attachment 403808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403808&action=review

>> Source/WebCore/Modules/webaudio/AudioNode.cpp:299
>> +    if (mode != ChannelCountMode::Max && mode != ChannelCountMode::ClampedMax && mode != ChannelCountMode::Explicit)
> 
> Why not we need this check? These seem to be the only values of ChannelCountMode.

Why *do* we need this check?
Comment 9 Chris Dumez 2020-07-08 14:29:49 PDT
Comment on attachment 403808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403808&action=review

> Source/WebCore/Modules/webaudio/AudioNode.cpp:310
> +ExceptionOr<void> AudioNode::setChannelInterpretation(const ChannelInterpretation interpretation)

Drop the const.
Comment 10 Clark Wang 2020-07-09 07:22:15 PDT
Created attachment 403864 [details]
Patch
Comment 11 Chris Dumez 2020-07-09 08:36:37 PDT
Comment on attachment 403864 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403864&action=review

r=me with nit fix

> Source/WebCore/Modules/webaudio/AudioNode.h:183
> +    ExceptionOr<void> setChannelInterpretation(const ChannelInterpretation);

Drop the const.
Comment 12 Clark Wang 2020-07-09 08:44:23 PDT
Created attachment 403868 [details]
Patch
Comment 13 EWS 2020-07-09 09:31:38 PDT
Committed r264176: <https://trac.webkit.org/changeset/264176>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403868 [details].
Comment 14 Radar WebKit Bug Importer 2020-07-09 09:32:16 PDT
<rdar://problem/65275132>