* Flushes all pending encode operations and waits for completion.
()
| 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(); |
nothing calls this directly
no test coverage detected