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

Method clone

src/audio_data.ts:299–319  ·  view source on GitHub ↗

* Creates a copy of this audio data.

()

Source from the content-addressed store, hash-verified

297 * Creates a copy of this audio data.
298 */
299 clone(): AudioData {
300 this.ensureNotClosed();
301
302 if (this._data instanceof Frame) {
303 const clone = this._data.clone();
304 if (!clone) {
305 throw new Error('Failed to clone AVFrame.');
306 }
307
308 return new AudioDataPolyfill(clone);
309 } else {
310 return new AudioData({
311 format: this.format!,
312 sampleRate: this.sampleRate,
313 numberOfFrames: this.numberOfFrames,
314 numberOfChannels: this.numberOfChannels,
315 timestamp: this.timestamp,
316 data: this._data!,
317 });
318 }
319 }
320
321 /**
322 * Closes the audio data and releases all resources.

Callers

nothing calls this directly

Calls 1

ensureNotClosedMethod · 0.95

Tested by

no test coverage detected