Skip to content

Clarify AudioFrame data 'snapshotting' behavior for ctor() and clone() #197

Closed
@tguilbert-google

Description

@tguilbert-google

The spec should make it clear that in the following scenario:

let buffer = new AudioBuffer(...);
let frame = new AudioFrame(buffer);

let clone_a = frame.clone();
// Modify frame.buffer
let clone_b = frame.clone();

clone_a and clone_b should have the same data due to snapshotting, despite frame.buffer being modified in between.

The spec should also clarify what happens in this scenario:

let buffer = new AudioBuffer(...);
let frame_a = new AudioFrame(buffer);
// Modify buffer, what happens to frame_a.buffer?
let frame_b = new AudioFrame(buffer);

In the current Chrome implementation, frame_a.buffer is also modified when buffer is modified, which means that from JS' POV, frame_a and frame_b are the same, but internally, their data snapshot is different.

We could (lazily) create a new buffer when AudioFrames are created to avoid this confusion (incurring an extra copy), or keep as is, but it would be an easy mistake to make as a developer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions