* Closes the decoder and releases all resources.
()
| 328 | * Closes the decoder and releases all resources. |
| 329 | */ |
| 330 | close() { |
| 331 | // Spec: Close AudioDecoder (with exception) |
| 332 | // 1. Run the Reset AudioDecoder algorithm with exception. |
| 333 | // 2. Set state to "closed". |
| 334 | // 3. Clear [[codec implementation]] and release associated system resources. |
| 335 | // 4. If exception is not an AbortError DOMException, invoke the [[error callback]] with exception. |
| 336 | |
| 337 | this._state = 'closed'; |
| 338 | this.currentConfigId++; |
| 339 | |
| 340 | // Reset logic inline (abort work, reject flushes) |
| 341 | if (this._decodeQueueSize > 0) { |
| 342 | this._decodeQueueSize = 0; |
| 343 | this.decrementQueue(); // Actually just schedule event |
| 344 | } |
| 345 | |
| 346 | for (const p of this._pendingFlushResolvers) { |
| 347 | p.reject(new DOMException('Decoder closed', 'AbortError')); |
| 348 | } |
| 349 | this._pendingFlushResolvers = []; |
| 350 | |
| 351 | // Release resources |
| 352 | this.codecContext?.freeContext(); |
| 353 | this.codecContext = null; |
| 354 | this.frame.free(); |
| 355 | this.packet.free(); |
| 356 | this.ondequeue = null; |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Resets the decoder to an unconfigured state. |
no test coverage detected