mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #21906 - Manishearth:minor-webaudio-fixes, r=ferjm
Minor WebAudio fixes Stuff I discovered whilst working on https://github.com/servo/media/pull/148 r? @ferjm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21906) <!-- Reviewable:end -->
This commit is contained in:
commit
ddcb72f750
3 changed files with 7 additions and 5 deletions
|
@ -20,10 +20,10 @@ use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer
|
|||
use std::cmp::min;
|
||||
use std::ptr::{self, NonNull};
|
||||
|
||||
// This range is defined by the spec.
|
||||
// Spec mandates at least [8000, 96000], we use [8000, 192000] to match Firefox
|
||||
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer
|
||||
pub const MIN_SAMPLE_RATE: f32 = 8000.;
|
||||
pub const MAX_SAMPLE_RATE: f32 = 96000.;
|
||||
pub const MAX_SAMPLE_RATE: f32 = 192000.;
|
||||
|
||||
type JSAudioChannel = Heap<*mut JSObject>;
|
||||
|
||||
|
|
|
@ -151,10 +151,14 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
|
|||
task!(resolve: move || {
|
||||
let this = this.root();
|
||||
let processed_audio = processed_audio.lock().unwrap();
|
||||
let processed_audio: Vec<_> = processed_audio
|
||||
let mut processed_audio: Vec<_> = processed_audio
|
||||
.chunks(this.length as usize)
|
||||
.map(|channel| channel.to_vec())
|
||||
.collect();
|
||||
// it can end up being empty if the task failed
|
||||
if processed_audio.len() != this.length as usize {
|
||||
processed_audio.resize(this.length as usize, Vec::new())
|
||||
}
|
||||
let buffer = AudioBuffer::new(
|
||||
&this.global().as_window(),
|
||||
this.channel_count,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue