diff --git a/Cargo.lock b/Cargo.lock index 51549470b32..ae734a32cd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3076,7 +3076,7 @@ dependencies = [ [[package]] name = "servo-media" version = "0.1.0" -source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748" +source = "git+https://github.com/servo/media#9968654a5602adfcdc01d6a9ba9d54fd8b341eaf" dependencies = [ "servo-media-audio 0.1.0 (git+https://github.com/servo/media)", "servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)", @@ -3085,7 +3085,7 @@ dependencies = [ [[package]] name = "servo-media-audio" version = "0.1.0" -source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748" +source = "git+https://github.com/servo/media#9968654a5602adfcdc01d6a9ba9d54fd8b341eaf" dependencies = [ "byte-slice-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3097,7 +3097,7 @@ dependencies = [ [[package]] name = "servo-media-gstreamer" version = "0.1.0" -source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748" +source = "git+https://github.com/servo/media#9968654a5602adfcdc01d6a9ba9d54fd8b341eaf" dependencies = [ "byte-slice-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "gstreamer 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3203,7 +3203,7 @@ dependencies = [ [[package]] name = "servo_media_derive" version = "0.1.0" -source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748" +source = "git+https://github.com/servo/media#9968654a5602adfcdc01d6a9ba9d54fd8b341eaf" dependencies = [ "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/script/dom/audionode.rs b/components/script/dom/audionode.rs index 3f4093d08c5..d193c9d77d9 100644 --- a/components/script/dom/audionode.rs +++ b/components/script/dom/audionode.rs @@ -97,8 +97,22 @@ impl AudioNodeMethods for AudioNode { } // https://webaudio.github.io/web-audio-api/#dom-audionode-connect-destinationparam-output - fn Connect_(&self, _: &AudioParam, _: u32) -> Fallible<()> { - // TODO + fn Connect_(&self, dest: &AudioParam, output: u32) -> Fallible<()> { + if self.context != dest.context() { + return Err(Error::InvalidAccess); + } + + if output >= self.NumberOfOutputs() { + return Err(Error::IndexSize); + } + + // servo-media takes care of ignoring duplicated connections. + + self.context.audio_context_impl().connect_ports( + self.node_id().output(output), + dest.node_id().param(dest.param_type()), + ); + Ok(()) } @@ -143,14 +157,20 @@ impl AudioNodeMethods for AudioNode { } // https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect - fn Disconnect_____(&self, _: &AudioParam) -> ErrorResult { - // TODO + fn Disconnect_____(&self, param: &AudioParam) -> ErrorResult { + self.context + .audio_context_impl() + .disconnect_to(self.node_id(), + param.node_id().param(param.param_type())); Ok(()) } // https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect - fn Disconnect______(&self, _: &AudioParam, _: u32) -> ErrorResult { - // TODO + fn Disconnect______(&self, param: &AudioParam, out: u32) -> ErrorResult { + self.context + .audio_context_impl() + .disconnect_output_between_to(self.node_id().output(out), + param.node_id().param(param.param_type())); Ok(()) } diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 964d4264d7f..db73619180f 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -78,6 +78,18 @@ impl AudioParam { fn message_node(&self, message: AudioNodeMessage) { self.context.audio_context_impl().message_node(self.node, message); } + + pub fn context(&self) -> &BaseAudioContext { + &self.context + } + + pub fn node_id(&self) -> NodeId { + self.node + } + + pub fn param_type(&self) -> ParamType { + self.param + } } impl AudioParamMethods for AudioParam { diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 18cb0062023..f8336e6a85d 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -423,6 +423,13 @@ impl PartialEq for Dom { } } +impl<'a, T: DomObject> PartialEq<&'a T> for Dom { + fn eq(&self, other: &&'a T) -> bool { + *self == Dom::from_ref(*other) + } +} + + impl Eq for Dom {} impl PartialEq for LayoutDom {