* Resets the decoder to an unconfigured state.
()
| 411 | * Resets the decoder to an unconfigured state. |
| 412 | */ |
| 413 | reset() { |
| 414 | // Spec 4.6: Reset VideoDecoder (with exception) |
| 415 | // 1. If state is "closed", throw an InvalidStateError. |
| 416 | if (this._state === 'closed') { |
| 417 | throw new DOMException('Cannot reset closed decoder', 'InvalidStateError'); |
| 418 | } |
| 419 | |
| 420 | // 2. Set state to "unconfigured". |
| 421 | this._state = 'unconfigured'; |
| 422 | |
| 423 | // 3. Signal [[codec implementation]] to cease producing output (invalidate ID). |
| 424 | this.currentConfigId++; |
| 425 | |
| 426 | // 4. Remove all control messages (handled by ID check). |
| 427 | |
| 428 | // 5. If [[decodeQueueSize]] is greater than zero... |
| 429 | if (this._decodeQueueSize > 0) { |
| 430 | this._decodeQueueSize = 0; |
| 431 | this.decrementQueue(); // Actually just schedule event |
| 432 | } |
| 433 | |
| 434 | // 6. For each promise in [[pending flush promises]]: Reject promise with exception. |
| 435 | for (const p of this.pendingFlushResolvers) { |
| 436 | p.reject(new DOMException('Decoder reset', 'AbortError')); |
| 437 | } |
| 438 | this.pendingFlushResolvers = []; |
| 439 | |
| 440 | // Cleanup context (implied by unconfigured state) |
| 441 | this.codecContext?.freeContext(); |
| 442 | this.codecContext = null; |
| 443 | } |
| 444 | |
| 445 | private handleAsyncError(e: unknown) { |
| 446 | const error = e instanceof DOMException |
nothing calls this directly
no test coverage detected