Bug 215093

Summary: Add constructor for GainNode
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web AudioAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, clark_wang, eric.carlson, esprehn+autocc, ews-watchlist, ggaren, glenn, gyuyoung.kim, jer.noble, kondapallykalyan, philipj, ryuan.choi, sergio, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 212611    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2020-08-03 12:11:17 PDT
Add constructor for GainNode:
- https://www.w3.org/TR/webaudio/#gainnode
Comment 1 Chris Dumez 2020-08-03 13:00:03 PDT
Created attachment 405856 [details]
Patch
Comment 2 Eric Carlson 2020-08-03 13:21:48 PDT
Comment on attachment 405856 [details]
Patch

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

> Source/WebCore/Modules/webaudio/GainNode.cpp:59
> +    auto result = gainNode->setChannelCount(options.channelCount.valueOr(2));
> +    if (result.hasException())
> +        return result.releaseException();
> +
> +    result = gainNode->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
> +    if (result.hasException())
> +        return result.releaseException();
> +
> +    result = gainNode->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
> +    if (result.hasException())
> +        return result.releaseException();

This coded is duplicated in at least six nodes now. It would be better to have an AudioNode constructor or method that takes an AudioNodeOptions.

> Source/WebCore/Modules/webaudio/GainNode.h:42
> +    static ExceptionOr<Ref<GainNode>> create(BaseAudioContext& context, const GainOptions& = { });

Won't the bindings generator always pass a default-initialized dictionary?
Comment 3 Chris Dumez 2020-08-03 13:28:18 PDT
Comment on attachment 405856 [details]
Patch

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

>> Source/WebCore/Modules/webaudio/GainNode.cpp:59
>> +        return result.releaseException();
> 
> This coded is duplicated in at least six nodes now. It would be better to have an AudioNode constructor or method that takes an AudioNodeOptions.

Yes I agree with you. The default values (when not specified in the dictionary) differ from node to node though so we have to watch out for that.
I will try and find a good way to factor this is a follow-up patch. Maybe it can wait until we're done adding all constructor to avoid conflicting.

>> Source/WebCore/Modules/webaudio/GainNode.h:42
>> +    static ExceptionOr<Ref<GainNode>> create(BaseAudioContext& context, const GainOptions& = { });
> 
> Won't the bindings generator always pass a default-initialized dictionary?

Yes, but this is also called from BaseAudioContext::createGain() above.
Comment 4 EWS 2020-08-03 14:51:17 PDT
Tools/Scripts/svn-apply failed to apply attachment 405856 [details] to trunk.
Please resolve the conflicts and upload a new patch.
Comment 5 Chris Dumez 2020-08-03 14:54:03 PDT
Created attachment 405868 [details]
Patch
Comment 6 Chris Dumez 2020-08-03 15:41:37 PDT
Comment on attachment 405868 [details]
Patch

Clearing flags on attachment: 405868

Committed r265227: <https://trac.webkit.org/changeset/265227>
Comment 7 Chris Dumez 2020-08-03 15:41:39 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2020-08-03 16:25:27 PDT
<rdar://problem/66497105>