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

Method flush

src/audio_encoder.ts:573–588  ·  view source on GitHub ↗

* Flushes all pending encode operations and waits for completion.

()

Source from the content-addressed store, hash-verified

571 * Flushes all pending encode operations and waits for completion.
572 */
573 async flush() {
574 // Spec: If [[state]] is not "configured", return a promise rejected with InvalidStateError DOMException.
575 if (this._state !== 'configured') {
576 return Promise.reject(new DOMException('Encoder not configured', 'InvalidStateError'));
577 }
578
579 // Spec: Let promise be a new Promise. Append promise to [[pending flush promises]].
580 return new Promise<void>((resolve, reject) => {
581 this.pendingFlushResolvers.push({ resolve, reject });
582
583 // Spec: Queue a control message to flush the codec...
584 this.flushInternal(this.currentConfigId, resolve).catch((e) => {
585 this.handleAsyncError(e);
586 });
587 });
588 }
589
590 private async flushInternal(configId: number, resolve: () => void) {
591 using lock = this.mutex.lock();

Callers

nothing calls this directly

Calls 2

flushInternalMethod · 0.95
handleAsyncErrorMethod · 0.95

Tested by

no test coverage detected