mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Fix construction of destination node (#6)
* Fix comparison of audiocontexts * Fix comparison * Fix destination node construction
This commit is contained in:
parent
6ac4b4b8e0
commit
723f1b0582
2 changed files with 14 additions and 13 deletions
|
@ -69,6 +69,7 @@ impl AudioNodeMethods for AudioNode {
|
||||||
destination: &AudioNode,
|
destination: &AudioNode,
|
||||||
output: u32,
|
output: u32,
|
||||||
input: u32) -> Fallible<DomRoot<AudioNode>> {
|
input: u32) -> Fallible<DomRoot<AudioNode>> {
|
||||||
|
|
||||||
if self.context != destination.context {
|
if self.context != destination.context {
|
||||||
return Err(Error::InvalidAccess);
|
return Err(Error::InvalidAccess);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::root::DomRoot;
|
use dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use dom::domexception::{DOMErrorName, DOMException};
|
use dom::domexception::{DOMErrorName, DOMException};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::gainnode::GainNode;
|
use dom::gainnode::GainNode;
|
||||||
|
@ -65,7 +65,7 @@ pub struct BaseAudioContext {
|
||||||
#[ignore_malloc_size_of = "servo_media"]
|
#[ignore_malloc_size_of = "servo_media"]
|
||||||
audio_context_impl: Rc<AudioContext>,
|
audio_context_impl: Rc<AudioContext>,
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
||||||
destination: Option<DomRoot<AudioDestinationNode>>,
|
destination: MutNullableDom<AudioDestinationNode>,
|
||||||
/// Resume promises which are soon to be fulfilled by a queued task.
|
/// Resume promises which are soon to be fulfilled by a queued task.
|
||||||
#[ignore_malloc_size_of = "promises are hard"]
|
#[ignore_malloc_size_of = "promises are hard"]
|
||||||
in_flight_resume_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, ErrorResult)>>,
|
in_flight_resume_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, ErrorResult)>>,
|
||||||
|
@ -87,7 +87,7 @@ pub struct BaseAudioContext {
|
||||||
impl BaseAudioContext {
|
impl BaseAudioContext {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new_inherited(
|
pub fn new_inherited(
|
||||||
global: &GlobalScope,
|
_: &GlobalScope,
|
||||||
options: BaseAudioContextOptions,
|
options: BaseAudioContextOptions,
|
||||||
) -> BaseAudioContext {
|
) -> BaseAudioContext {
|
||||||
let options = match options {
|
let options = match options {
|
||||||
|
@ -97,10 +97,10 @@ impl BaseAudioContext {
|
||||||
|
|
||||||
let sample_rate = options.sample_rate;
|
let sample_rate = options.sample_rate;
|
||||||
|
|
||||||
let mut context = BaseAudioContext {
|
let context = BaseAudioContext {
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
audio_context_impl: Rc::new(ServoMedia::get().unwrap().create_audio_context(options.into())),
|
audio_context_impl: Rc::new(ServoMedia::get().unwrap().create_audio_context(options.into())),
|
||||||
destination: None,
|
destination: Default::default(),
|
||||||
in_flight_resume_promises_queue: Default::default(),
|
in_flight_resume_promises_queue: Default::default(),
|
||||||
pending_resume_promises: Default::default(),
|
pending_resume_promises: Default::default(),
|
||||||
decode_resolvers: Default::default(),
|
decode_resolvers: Default::default(),
|
||||||
|
@ -108,13 +108,6 @@ impl BaseAudioContext {
|
||||||
state: Cell::new(AudioContextState::Suspended),
|
state: Cell::new(AudioContextState::Suspended),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut options = AudioNodeOptions::empty();
|
|
||||||
options.channelCount = Some(2);
|
|
||||||
options.channelCountMode = Some(ChannelCountMode::Explicit);
|
|
||||||
options.channelInterpretation = Some(ChannelInterpretation::Speakers);
|
|
||||||
|
|
||||||
context.destination = Some(AudioDestinationNode::new(global, &context, &options));
|
|
||||||
|
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +273,14 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
|
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
||||||
fn Destination(&self) -> DomRoot<AudioDestinationNode> {
|
fn Destination(&self) -> DomRoot<AudioDestinationNode> {
|
||||||
DomRoot::from_ref(self.destination.as_ref().unwrap())
|
let global = self.global();
|
||||||
|
self.destination.or_init(|| {
|
||||||
|
let mut options = AudioNodeOptions::empty();
|
||||||
|
options.channelCount = Some(2);
|
||||||
|
options.channelCountMode = Some(ChannelCountMode::Explicit);
|
||||||
|
options.channelInterpretation = Some(ChannelInterpretation::Speakers);
|
||||||
|
AudioDestinationNode::new(&global, self, &options)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
|
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue