mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Make OfflineAudioContextOptions spec compliant
This commit is contained in:
parent
19e4c627a3
commit
3b8cb83e04
2 changed files with 21 additions and 25 deletions
|
@ -41,22 +41,32 @@ pub struct OfflineAudioContext {
|
|||
|
||||
impl OfflineAudioContext {
|
||||
#[allow(unrooted_must_root)]
|
||||
fn new_inherited(options: &OfflineAudioContextOptions) -> OfflineAudioContext {
|
||||
fn new_inherited(channel_count: u32,
|
||||
length: u32,
|
||||
sample_rate: f32) -> OfflineAudioContext {
|
||||
let options = ServoMediaOfflineAudioContextOptions {
|
||||
channels: channel_count as u8,
|
||||
length: length as usize,
|
||||
sample_rate,
|
||||
};
|
||||
let context = BaseAudioContext::new_inherited(
|
||||
BaseAudioContextOptions::OfflineAudioContext(options.into()),
|
||||
BaseAudioContextOptions::OfflineAudioContext(options),
|
||||
);
|
||||
OfflineAudioContext {
|
||||
context,
|
||||
channel_count: options.numberOfChannels,
|
||||
length: options.length,
|
||||
channel_count,
|
||||
length,
|
||||
rendering_started: Cell::new(false),
|
||||
pending_rendering_promise: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
fn new(window: &Window, options: &OfflineAudioContextOptions) -> DomRoot<OfflineAudioContext> {
|
||||
let context = OfflineAudioContext::new_inherited(options);
|
||||
fn new(window: &Window,
|
||||
channel_count: u32,
|
||||
length: u32,
|
||||
sample_rate: f32) -> DomRoot<OfflineAudioContext> {
|
||||
let context = OfflineAudioContext::new_inherited(channel_count, length, sample_rate);
|
||||
reflect_dom_object(Box::new(context), window, OfflineAudioContextBinding::Wrap)
|
||||
}
|
||||
|
||||
|
@ -64,7 +74,7 @@ impl OfflineAudioContext {
|
|||
window: &Window,
|
||||
options: &OfflineAudioContextOptions,
|
||||
) -> Fallible<DomRoot<OfflineAudioContext>> {
|
||||
Ok(OfflineAudioContext::new(window, options))
|
||||
Ok(OfflineAudioContext::new(window, options.numberOfChannels, options.length, *options.sampleRate))
|
||||
}
|
||||
|
||||
pub fn Constructor_(
|
||||
|
@ -82,11 +92,7 @@ impl OfflineAudioContext {
|
|||
return Err(Error::NotSupported);
|
||||
}
|
||||
|
||||
let mut options = OfflineAudioContextOptions::empty();
|
||||
options.numberOfChannels = number_of_channels;
|
||||
options.length = length;
|
||||
options.sampleRate = sample_rate;
|
||||
Ok(OfflineAudioContext::new(window, &options))
|
||||
Ok(OfflineAudioContext::new(window, number_of_channels, length, *sample_rate))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,13 +172,3 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
|
|||
promise
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a OfflineAudioContextOptions> for ServoMediaOfflineAudioContextOptions {
|
||||
fn from(options: &OfflineAudioContextOptions) -> Self {
|
||||
Self {
|
||||
channels: options.numberOfChannels as u8,
|
||||
length: options.length as usize,
|
||||
sample_rate: *options.sampleRate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
dictionary OfflineAudioContextOptions {
|
||||
unsigned long numberOfChannels = 1;
|
||||
unsigned long length = 0;
|
||||
float sampleRate = 48000.;
|
||||
required unsigned long length;
|
||||
required float sampleRate;
|
||||
};
|
||||
|
||||
[Exposed=Window,
|
||||
Constructor (optional OfflineAudioContextOptions contextOptions),
|
||||
Constructor (OfflineAudioContextOptions contextOptions),
|
||||
Constructor (unsigned long numberOfChannels, unsigned long length, float sampleRate)]
|
||||
interface OfflineAudioContext : BaseAudioContext {
|
||||
readonly attribute unsigned long length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue