Skip to content

Commit

Permalink
remove process check in registerProcessor, should follow spec and rul…
Browse files Browse the repository at this point in the history
…es defined in rendering audio graph 4.4.4
  • Loading branch information
b-ma committed May 11, 2024
1 parent 92646cc commit a34cc97
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions js/AudioWorkletGlobalScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
sampleRate,
} = workerData;

const kHiddenOptions = Symbol('node-web-audio-api:worklet-hidden-options');
const kWorkletCallableProcess = Symbol.for('node-web-audio-api:worklet-callable-process');
const kWorkletInputs = Symbol.for('node-web-audio-api:worklet-inputs');
const kWorkletOutputs = Symbol.for('node-web-audio-api:worklet-outputs');
const kWorkletParams = Symbol.for('node-web-audio-api:worklet-params');
Expand Down Expand Up @@ -74,13 +74,13 @@ globalThis.AudioWorkletProcessor = class AudioWorkletProcessor {
parameterDescriptors,
} = pendingProcessorConstructionData;

this.#port = port;

// @todo - Mark [[callable process]] as true, set to false in render quantum
// either "process" doese not exists, either it throws an error
this[kWorkletCallableProcess] = true;
// @todo - reuse Float32Arrays between calls + freeze arrays
this[kWorkletInputs] = new Array(numberOfInputs).fill([]);
// @todo - use `outputChannelCount`
this[kWorkletOutputs] = new Array(numberOfOutputs).fill([]);

// Object to be reused as `process` parameters argument
this[kWorkletParams] = {};
// Cache of 2 Float32Array (of length 128 and 1) for each param, to be reused on
Expand All @@ -93,6 +93,8 @@ globalThis.AudioWorkletProcessor = class AudioWorkletProcessor {
new Float32Array(1),
]
});

this.#port = port;
}

get port() {
Expand Down Expand Up @@ -127,10 +129,6 @@ globalThis.registerProcessor = function registerProcessor(name, processorCtor) {
throw new TypeError(`Cannot execute 'registerProcessor")' in 'AudoWorkletGlobalScope': argument 2 for name '${name}' is not is not a valid AudioWorkletProcessor`);
}

if (typeof processorCtor.prototype.process !== 'function') {
throw new TypeError(`Cannot execute 'registerProcessor' in 'AudoWorkletGlobalScope': AudioWorkletProcessor for name '${name}' must implement a 'proces' method`);
}

// must support Array, Set or iterators
let parameterDescriptorsValue = processorCtor.parameterDescriptors;

Expand Down

0 comments on commit a34cc97

Please sign in to comment.