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

Method flush

src/video_encoder.ts:575–590  ·  view source on GitHub ↗

* Flushes all pending encode operations and waits for completion.

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

flushInternalMethod · 0.95
handleAsyncErrorMethod · 0.95

Tested by

no test coverage detected