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

AudioWorkletNodeOptions.processorOptions should not default to null. #2011

Closed hoch closed 5 years ago

hoch commented 5 years ago

Describe the issue Because it is defaulting to null, the processor always get null for the field even the main scope option object is undefined. We should make it a plain object.

object processorOptions;

Where Is It https://webaudio.github.io/web-audio-api/#dictdef-audioworkletnodeoptions

guest271314 commented 5 years ago

Not gathering what the expected result is. Can you include short snippets of code detailing what the expected output is for each input where options are passed or not passed?

hoch commented 5 years ago

The setup code:

const node = new AudioWorkletNode(context, 'processor', nodeOptions);
class extends AudioWorkletProcessor {
  constructor(options){
    console.log(options);
  }
}

When nodeOptions = {}:

{numberOfInputs: 1, numberOfOutputs:1}

When nodeOptions = {foo: 'bar'}:

{numberOfInputs: 1, numberOfOutputs:1}

When nodeOptions = {foo:bar, processorOptions: {foo:'bar'}}:

{numberOfInputs: 1, numberOfOutputs:1, processorOptions: {foo:'bar'}}
hoch commented 5 years ago

From WG Telecon: Remove the nullable type and the default value from processorOptions.

karlt commented 5 years ago

I'm not aware of any benefit in processorOptions being nullable.

If the value could default to the empty object, then that would permit clients to test for members without throwing a TypeError when processorOptions is not specified, but I don't think it is possible to specify an empty object default in WebIDL.

So, yes, the proposed change seems the best option available.