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.06k stars 168 forks source link

[audioworklet] Moving AudioContextInfo to AudioWorkletGlobalScope #1326

Closed hoch closed 7 years ago

hoch commented 7 years ago

Currently AudioContextInfo is located at AudioWorkletProcessor, but it seems wasteful considering sampleRate and currentTime are identical to all instances in an AudioWorkletGlobalScope.

So I am proposing moving individual attributes of AudioContextInfo to AudioWorkletGlobalScope:

interface AudioWorkletGlobalScope : WorkletGlobalScope {
  void registerProcessor (DOMString name, VoidFunction processorCtor);
  readonly attribute double currentTime;
  readonly attribute float sampleRate;
}

Calling AudioContextInfo() creates a dictionary, so accessing the primitive values directly should be more efficient and less wasteful. (in terms of GC)

joeberkovitz commented 7 years ago

When fixing this, be sure to update the code examples.