Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all AudioBuffer WPTs #21602

Merged
merged 10 commits into from Sep 19, 2018

Apply start_in_channel to destination and not source during AudioBuff…

…er.CopyToChannel
  • Loading branch information
ferjm committed Sep 19, 2018
commit 10e8ab3892ce42c9a27d14beea1362b38284807e
@@ -287,14 +287,18 @@ impl AudioBufferMethods for AudioBuffer {
return Err(Error::IndexSize);
}

typedarray!(in(cx) let array: Float32Array = js_channel);
if let Ok(mut array) = array {
typedarray!(in(cx) let js_channel: Float32Array = js_channel);
if let Ok(mut js_channel) = js_channel {
let bytes_to_copy = min(self.length - start_in_channel, source.len() as u32) as usize;
let offset = start_in_channel as usize;
unsafe {
let data = &source.as_slice()[offset..offset + bytes_to_copy];
array.update(data);
(*self.shared_channels.borrow_mut()).buffers[channel_number as usize] = data.to_vec();
let data = &source.as_slice()[0..bytes_to_copy];
// Update shared channel.
let mut shared_channels = self.shared_channels.borrow_mut();
let shared_channel = shared_channels.data_chan_mut(channel_number as u8);
let (_, mut shared_channel) = shared_channel.split_at_mut(start_in_channel as usize);
shared_channel[0..bytes_to_copy].copy_from_slice(data);
// Update js channel.
js_channel.update(data);
}
} else {
return Err(Error::IndexSize);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.