diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2018-09-12 07:14:33 +0200 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2018-09-19 06:54:17 +0200 |
commit | 10e8ab3892ce42c9a27d14beea1362b38284807e (patch) | |
tree | 6a17c55039cc1c73f5478329cdec9fcbfd054e9b /components/script/dom/audiobuffer.rs | |
parent | e0e1f5f90035cf51e96f282f082fa9d90d7525f0 (diff) | |
download | servo-10e8ab3892ce42c9a27d14beea1362b38284807e.tar.gz servo-10e8ab3892ce42c9a27d14beea1362b38284807e.zip |
Apply start_in_channel to destination and not source during AudioBuffer.CopyToChannel
Diffstat (limited to 'components/script/dom/audiobuffer.rs')
-rw-r--r-- | components/script/dom/audiobuffer.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index 0b56325f7d9..16cc1d257cf 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -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); |