Skip to content

Commit

Permalink
Add AudioParam connection support
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth authored and ferjm committed Jul 30, 2018
1 parent 841fedd commit 00014b3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions components/script/dom/audionode.rs
Expand Up @@ -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(())
}

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

Expand Down
12 changes: 12 additions & 0 deletions components/script/dom/audioparam.rs
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions components/script/dom/bindings/root.rs
Expand Up @@ -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> {
Expand Down

0 comments on commit 00014b3

Please sign in to comment.