* Resets the encoder to an unconfigured state.
()
| 648 | * Resets the encoder to an unconfigured state. |
| 649 | */ |
| 650 | reset() { |
| 651 | // Spec: Reset AudioEncoder (with exception) |
| 652 | // 1. If state is "closed", throw an InvalidStateError. |
| 653 | if (this._state === 'closed') { |
| 654 | throw new DOMException('Cannot reset closed encoder', 'InvalidStateError'); |
| 655 | } |
| 656 | |
| 657 | // 2. Set state to "unconfigured". |
| 658 | this._state = 'unconfigured'; |
| 659 | |
| 660 | // 3. Signal [[codec implementation]] to cease producing output (invalidate ID). |
| 661 | this.currentConfigId++; |
| 662 | |
| 663 | // 4. Remove all control messages (handled by ID check). |
| 664 | |
| 665 | // 5. If [[encodeQueueSize]] is greater than zero... |
| 666 | if (this._encodeQueueSize > 0) { |
| 667 | this._encodeQueueSize = 0; |
| 668 | this.decrementQueue(); |
| 669 | } |
| 670 | |
| 671 | // 6. For each promise in [[pending flush promises]]: Reject promise with exception. |
| 672 | for (const p of this.pendingFlushResolvers) { |
| 673 | p.reject(new DOMException('Encoder reset', 'AbortError')); |
| 674 | } |
| 675 | this.pendingFlushResolvers = []; |
| 676 | |
| 677 | this.config = null; |
| 678 | this.codecContext?.freeContext(); |
| 679 | this.codecContext = null; |
| 680 | this.chunkOutputted = false; |
| 681 | this.aacAudioSpecificConfig = null; |
| 682 | this.resampledSampleCount = 0; |
| 683 | } |
| 684 | |
| 685 | private handleAsyncError(e: unknown) { |
| 686 | const error = e instanceof DOMException |
nothing calls this directly
no test coverage detected