media
media copied to clipboard
AudioBufferSourceNode: Implement linear extrapolation for endpoints
buffer-resampling.html (WPT test) fails because we interpolate the last sample with 0 when we output a sample with pos corresponding to buffer.len() - 1 < pos < buffer.len(). For playhead positions after the last sample, Chromium implemented linear extrapolation using the last two samples, and this seems to be needed to pass this test using a linear interpolation strategy (Firefox uses truncated sinc interpolation via libspeex-resample). The relevant code is https://github.com/servo/media/blob/86b9a2892af3774e42243ac84394a052719b2bf6/audio/buffer_source_node.rs#L399
Chromium does not support negative playbackRates, as far as I can tell, but in this case we would likely want to do an analogous extrapolation for playhead positions that are slightly before the first buffer sample.
https://github.com/WebAudio/web-audio-api/issues/2032
We should fix the code to match the test here, usually such bugs (when WPT disagrees with the spec) are spec bugs, and it makes sense for that to be the case here.