Allow overriding GainNode's settings from the constructor

This commit is contained in:
Manish Goregaokar 2018-09-03 18:51:03 +05:30
parent eb6aec37e9
commit 91b8cbe1db

View file

@ -30,14 +30,17 @@ impl GainNode {
pub fn new_inherited( pub fn new_inherited(
window: &Window, window: &Window,
context: &BaseAudioContext, context: &BaseAudioContext,
gain_options: &GainOptions, options: &GainOptions,
) -> GainNode { ) -> GainNode {
let mut node_options = AudioNodeOptions::empty(); let mut node_options = AudioNodeOptions::empty();
node_options.channelCount = Some(2); let count = options.parent.channelCount.unwrap_or(2);
node_options.channelCountMode = Some(ChannelCountMode::Max); let mode = options.parent.channelCountMode.unwrap_or(ChannelCountMode::Max);
node_options.channelInterpretation = Some(ChannelInterpretation::Speakers); 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( let node = AudioNode::new_inherited(
AudioNodeInit::GainNode(gain_options.into()), AudioNodeInit::GainNode(options.into()),
context, context,
&node_options, &node_options,
1, // inputs 1, // inputs