servo / media

Mozilla Public License 2.0
82 stars 54 forks source link

AudioBufferSourceNode: Adjust buffer_pos when loop endpoints change #297

Open collares opened 5 years ago

collares commented 5 years ago

See https://github.com/servo/media/blob/86b9a2892af3774e42243ac84394a052719b2bf6/audio/buffer_source_node.rs#L125

The spec doesn't clarify how the adjustment should be made. There's one thing to keep in mind: Even for fixed loop endpoints, self.buffer_pos can be slightly outside the loop bounds when process() starts; this is because we increment buffer_pos right after outputting a sample, but only loop right before outputting a sample. Any implementation must behave the same as this, because the playback algorithm (https://webaudio.github.io/web-audio-api/#playback-AudioBufferSourceNode) is normative.

collares commented 5 years ago

https://github.com/WebAudio/web-audio-api/issues/2033