From 91b8cbe1db88bef90d280b5cff9bb43b1fb95281 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 18:51:03 +0530 Subject: [PATCH] Allow overriding GainNode's settings from the constructor --- components/script/dom/gainnode.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index 5cdbd8a89c9..17c32b00352 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -30,14 +30,17 @@ impl GainNode { pub fn new_inherited( window: &Window, context: &BaseAudioContext, - gain_options: &GainOptions, + options: &GainOptions, ) -> GainNode { let mut node_options = AudioNodeOptions::empty(); - node_options.channelCount = Some(2); - node_options.channelCountMode = Some(ChannelCountMode::Max); - node_options.channelInterpretation = Some(ChannelInterpretation::Speakers); + let count = options.parent.channelCount.unwrap_or(2); + let mode = options.parent.channelCountMode.unwrap_or(ChannelCountMode::Max); + let interpretation = options.parent.channelInterpretation.unwrap_or(ChannelInterpretation::Speakers); + node_options.channelCount = Some(count); + node_options.channelCountMode = Some(mode); + node_options.channelInterpretation = Some(interpretation); let node = AudioNode::new_inherited( - AudioNodeInit::GainNode(gain_options.into()), + AudioNodeInit::GainNode(options.into()), context, &node_options, 1, // inputs