MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / close

Method close

src/audio_encoder.ts:623–645  ·  view source on GitHub ↗

* Closes the encoder and releases all resources.

()

Source from the content-addressed store, hash-verified

621 * Closes the encoder and releases all resources.
622 */
623 close() {
624 // Spec: Close AudioEncoder (with exception)
625 this._state = 'closed';
626 this.currentConfigId++;
627
628 if (this._encodeQueueSize > 0) {
629 this._encodeQueueSize = 0;
630 this.decrementQueue();
631 }
632
633 for (const p of this.pendingFlushResolvers) {
634 p.reject(new DOMException('Encoder closed', 'AbortError'));
635 }
636 this.pendingFlushResolvers = [];
637
638 this.codecContext?.freeContext();
639 this.codecContext = null;
640 this.ondequeue = null;
641 this.frame.free();
642 this.packet.free();
643 this.resampler?.free();
644 this.dstFrame?.free();
645 }
646
647 /**
648 * Resets the encoder to an unconfigured state.

Callers 2

handleAsyncErrorMethod · 0.95
encodeInternalMethod · 0.45

Calls 1

decrementQueueMethod · 0.95

Tested by

no test coverage detected