mirror of
https://github.com/davedoesdev/streamana.git
synced 2024-08-20 23:27:41 +08:00
23 lines
611 B
JavaScript
23 lines
611 B
JavaScript
import { UpdateLimiter } from './update-limiter.js';
|
|
|
|
class DummyProcessor extends AudioWorkletProcessor {
|
|
constructor(options) {
|
|
super(options);
|
|
this.stopped = false;
|
|
this.port.onmessage = () => this.stopped = true;
|
|
this.update_limiter = new UpdateLimiter(options.processorOptions.update_rate);
|
|
}
|
|
|
|
process() {
|
|
if (this.stopped) {
|
|
return false;
|
|
}
|
|
if (this.update_limiter.check()) {
|
|
this.port.postMessage({ type: 'update' });
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
registerProcessor('dummy-processor', DummyProcessor);
|