Add AudioParam connection support

This commit is contained in:
Manish Goregaokar 2018-07-19 14:46:23 -07:00 committed by Fernando Jiménez Moreno
parent 841fedda4f
commit 00014b3f16
4 changed files with 49 additions and 10 deletions

View file

@ -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(())
}

View file

@ -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 {

View file

@ -423,6 +423,13 @@ impl<T> PartialEq for Dom<T> {
}
}
impl<'a, T: DomObject> PartialEq<&'a T> for Dom<T> {
fn eq(&self, other: &&'a T) -> bool {
*self == Dom::from_ref(*other)
}
}
impl<T> Eq for Dom<T> {}
impl<T> PartialEq for LayoutDom<T> {