* Closes the encoder and releases all resources.
()
| 621 | * Closes the encoder and releases all resources. |
| 622 | */ |
| 623 | close() { |
| 624 | // Spec: Close AudioEncoder (with exception) |
| 625 | this._state = 'closed'; |
| 626 | this.currentConfigId++; |
| 627 | |
| 628 | if (this._encodeQueueSize > 0) { |
| 629 | this._encodeQueueSize = 0; |
| 630 | this.decrementQueue(); |
| 631 | } |
| 632 | |
| 633 | for (const p of this.pendingFlushResolvers) { |
| 634 | p.reject(new DOMException('Encoder closed', 'AbortError')); |
| 635 | } |
| 636 | this.pendingFlushResolvers = []; |
| 637 | |
| 638 | this.codecContext?.freeContext(); |
| 639 | this.codecContext = null; |
| 640 | this.ondequeue = null; |
| 641 | this.frame.free(); |
| 642 | this.packet.free(); |
| 643 | this.resampler?.free(); |
| 644 | this.dstFrame?.free(); |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * Resets the encoder to an unconfigured state. |
no test coverage detected