Skip to content

Commit

Permalink
AudioBuffer: Track sample rate
Browse files Browse the repository at this point in the history
  • Loading branch information
collares committed Aug 19, 2019
1 parent 8fd0675 commit 992e7ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/script/dom/audiobuffer.rs
Expand Up @@ -115,8 +115,11 @@ impl AudioBuffer {
// Initialize the underlying channels data with initial data provided by
// the user or silence otherwise.
fn set_initial_data(&self, initial_data: Option<&[Vec<f32>]>) {
let mut channels =
ServoMediaAudioBuffer::new(self.number_of_channels as u8, self.length as usize);
let mut channels = ServoMediaAudioBuffer::new(
self.number_of_channels as u8,
self.length as usize,
self.sample_rate,
);
for channel in 0..self.number_of_channels {
channels.buffers[channel as usize] = match initial_data {
Some(data) => data[channel as usize].clone(),
Expand Down Expand Up @@ -164,8 +167,11 @@ impl AudioBuffer {
// https://webaudio.github.io/web-audio-api/#acquire-the-content
#[allow(unsafe_code)]
fn acquire_contents(&self) -> Option<ServoMediaAudioBuffer> {
let mut result =
ServoMediaAudioBuffer::new(self.number_of_channels as u8, self.length as usize);
let mut result = ServoMediaAudioBuffer::new(
self.number_of_channels as u8,
self.length as usize,
self.sample_rate,
);
let cx = self.global().get_cx();
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
// Step 1.
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/audiobuffersourcenode.rs
Expand Up @@ -224,6 +224,7 @@ impl AudioBufferSourceNodeMethods for AudioBufferSourceNode {
));
}
}

self.source_node
.upcast::<AudioScheduledSourceNode>()
.Start(when)
Expand Down

0 comments on commit 992e7ba

Please sign in to comment.