Skip to content

Commit f511c90

Browse files
jyavenardpadenot
authored andcommitted
Specify format of buffer we're copying into
Per spec https://w3c.github.io/webcodecs/#dom-audiodatacopytooptions-format if the format is not specified, we are to use the same format as the source. Which could be interleaved as the format for decoding isn't specified. Calling copyTo with a planeIndex of 0 with an interleaved buffer will attempt to copy all planes. So we just set the destination format to be f32-planar. This allows playback to start on browsers that aren't Blink based (Firefox, Safari)
1 parent 47e3955 commit f511c90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

samples/lib/audio_renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class AudioRenderer {
176176
debugLog(`bufferAudioData() ts:${data.timestamp} durationSec:${data.duration / 1000000}`);
177177
// Write to temporary planar arrays, and interleave into the ring buffer.
178178
for (var i = 0; i < this.channelCount; i++) {
179-
data.copyTo(this.interleavingBuffers[i], { planeIndex: i });
179+
data.copyTo(this.interleavingBuffers[i], { planeIndex: i, format: "f32-planar" });
180180
}
181181
// Write the data to the ring buffer. Because it wraps around, there is
182182
// potentially two copyTo to do.

0 commit comments

Comments
 (0)