MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / close

Method close

src/video_decoder.ts:381–408  ·  view source on GitHub ↗

* Closes the decoder and releases all resources.

()

Source from the content-addressed store, hash-verified

379 * Closes the decoder and releases all resources.
380 */
381 close() {
382 // Spec 4.6: Close VideoDecoder (with exception)
383 // 1. Run the Reset VideoDecoder algorithm with exception.
384 // 2. Set state to "closed".
385 // 3. Clear [[codec implementation]] and release associated system resources.
386 // 4. If exception is not an AbortError DOMException, invoke the [[error callback]] with exception.
387
388 this._state = 'closed';
389 this.currentConfigId++;
390
391 // Reset logic inline (abort work, reject flushes)
392 if (this._decodeQueueSize > 0) {
393 this._decodeQueueSize = 0;
394 this.decrementQueue(); // Actually just schedule event
395 }
396
397 for (const p of this.pendingFlushResolvers) {
398 p.reject(new DOMException('Decoder closed', 'AbortError'));
399 }
400 this.pendingFlushResolvers = [];
401
402 // Release resources
403 this.codecContext?.freeContext();
404 this.codecContext = null;
405 this.frame.free();
406 this.packet.free();
407 this.ondequeue = null;
408 }
409
410 /**
411 * Resets the decoder to an unconfigured state.

Callers 1

handleAsyncErrorMethod · 0.95

Calls 1

decrementQueueMethod · 0.95

Tested by

no test coverage detected