Skip to content

Commit

Permalink
Specify format of buffer we're copying into
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jyavenard authored and padenot committed Jan 7, 2025
1 parent 47e3955 commit f511c90
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion samples/lib/audio_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class AudioRenderer {
debugLog(`bufferAudioData() ts:${data.timestamp} durationSec:${data.duration / 1000000}`);
// Write to temporary planar arrays, and interleave into the ring buffer.
for (var i = 0; i < this.channelCount; i++) {
data.copyTo(this.interleavingBuffers[i], { planeIndex: i });
data.copyTo(this.interleavingBuffers[i], { planeIndex: i, format: "f32-planar" });
}
// Write the data to the ring buffer. Because it wraps around, there is
// potentially two copyTo to do.
Expand Down

0 comments on commit f511c90

Please sign in to comment.