* Resets the decoder to an unconfigured state.
()
| 360 | * Resets the decoder to an unconfigured state. |
| 361 | */ |
| 362 | reset() { |
| 363 | // Spec: Reset AudioDecoder (with exception) |
| 364 | // 1. If state is "closed", throw an InvalidStateError. |
| 365 | if (this._state === 'closed') { |
| 366 | throw new DOMException('Cannot reset closed decoder', 'InvalidStateError'); |
| 367 | } |
| 368 | |
| 369 | // 2. Set state to "unconfigured". |
| 370 | this._state = 'unconfigured'; |
| 371 | |
| 372 | // 3. Signal [[codec implementation]] to cease producing output (invalidate ID). |
| 373 | this.currentConfigId++; |
| 374 | |
| 375 | // 4. Remove all control messages (handled by ID check). |
| 376 | |
| 377 | // 5. If [[decodeQueueSize]] is greater than zero... |
| 378 | if (this._decodeQueueSize > 0) { |
| 379 | this._decodeQueueSize = 0; |
| 380 | this.decrementQueue(); // Actually just schedule event |
| 381 | } |
| 382 | |
| 383 | // 6. For each promise in [[pending flush promises]]: Reject promise with exception. |
| 384 | for (const p of this._pendingFlushResolvers) { |
| 385 | p.reject(new DOMException('Decoder reset', 'AbortError')); |
| 386 | } |
| 387 | this._pendingFlushResolvers = []; |
| 388 | |
| 389 | // Cleanup context (implied by unconfigured state) |
| 390 | this.codecContext?.freeContext(); |
| 391 | this.codecContext = null; |
| 392 | } |
| 393 | |
| 394 | private handleAsyncError(e: unknown) { |
| 395 | const error = e instanceof DOMException |
nothing calls this directly
no test coverage detected