WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 167 forks source link

parameters and return value of processorCtor parameter to AudioWorkletGlobalScope.registerProcessor() #1839

Closed karlt closed 5 years ago

karlt commented 5 years ago

AudioWorkletGlobalScope.registerProcessor() is declared in webidl with the processorCtor parameter of type VoidFunction. https://webaudio.github.io/web-audio-api/#audioworkletglobalscope "The VoidFunction callback function type is used for representing function values that take no arguments and do not return any value." https://heycam.github.io/webidl/#VoidFunction

However, "the construction of an AudioWorkletProcessor" requires calling Construct() with a list of options, and so the processorCtor would be called with an argument.

Further, the return value is from the constructor is used in the Construct algorithm, and so I'm not clear how a missing return value would be enforced or ignored. https://tc39.github.io/ecma262/#sec-construct https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

karlt commented 5 years ago

Blink declares callback BlinkAudioWorkletProcessorConstructor = any (any options); https://chromium.googlesource.com/chromium/src/+blame/52dded60a7c8b0c66637c35a9450744d99ef1581/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope.idl#21 which is the same as Function. https://heycam.github.io/webidl/#Function So I guess s/VoidFunction/Function/ is appropriate here.

karlt commented 5 years ago

Oh, I missed the ... in Function. Function has multiple arguments, and so I guess it is better to have something similar to the blink webidl to clarify that only one parameter will be used.

hoch commented 5 years ago

I can add callback AudioWorkletProcessorConstructor = any (any options) in the IDL of AudioWorkletGlobalScope.