New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constant source node DOM #23152
Closed
+154
−19
Closed
Constant source node DOM #23152
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
06b54ac
Add ConstantSourceNode webidl
josephhutch 1648c06
Add empty constantsourcenode.rs
josephhutch eab6389
Update constantsourcenode dom - Needs more work
josephhutch d7177c6
Resolved import errors
hustlerman 56d2c13
Implemented ConstantSourceNode Methods
hustlerman 894ea9e
Enabled CreateConstantSource API
hustlerman File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Update constantsourcenode dom - Needs more work
- Loading branch information
commit eab63895b886bc5215dcf6c96ae6938514e56e7c
| @@ -0,0 +1,85 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| use crate::dom::audioparam::AudioParam; | ||
| use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; | ||
| use crate::dom::baseaudiocontext::BaseAudioContext; | ||
| use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ | ||
| ChannelCountMode, ChannelInterpretation, | ||
| }; | ||
| use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; | ||
| use crate::dom::bindings::error::Fallible; | ||
| use crate::dom::bindings::reflector::reflect_dom_object; | ||
| use crate::dom::bindings::root::{Dom, DomRoot}; | ||
| use crate::dom::window::Window; | ||
| use dom_struct::dom_struct; | ||
| use servo_media::audio::node::AudioNodeInit; | ||
| use servo_media::audio::constant_source_node::ConstantSourceNodeOptions; | ||
| use servo_media::audio::param::ParamType; | ||
| use std::f32; | ||
|
|
||
| #[dom_struct] | ||
| pub struct ConstantSourceNode { | ||
| source_node: AudioScheduledSourceNode, | ||
| offset: Dom<AudioParam>, | ||
| } | ||
|
|
||
| impl ConstantSourceNode { | ||
| #[allow(unrooted_must_root)] | ||
| pub fn new_inherited( | ||
| window: &Window, | ||
| context: &BaseAudioContext, | ||
| options: &ConstantSourceOptions, | ||
| ) -> Fallible<ConstantSourceNode> { | ||
| let node_options = | ||
| options | ||
| .parent | ||
| .unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers); | ||
| let source_node = AudioScheduledSourceNode::new_inherited( | ||
| AudioNodeInit::ConstantSourceNode(options.into()), | ||
| context, | ||
| node_options, | ||
| 0, /* inputs */ | ||
| 1, /* outputs */ | ||
| )?; | ||
| let node_id = source_node.node().node_id(); | ||
| let offset = AudioParam::new( | ||
| window, | ||
| context, | ||
| node_id, | ||
| ParamType::Offset, | ||
| AutomationRate::A_rate, | ||
| 1., | ||
|
||
| f32::MIN, | ||
| f32::MAX, | ||
| ); | ||
|
|
||
| Ok(ConstantSourceNode { | ||
| source_node, | ||
| offset: Dom::from_ref(&offset), | ||
| }) | ||
| } | ||
|
|
||
| #[allow(unrooted_must_root)] | ||
| pub fn new( | ||
| window: &Window, | ||
| context: &BaseAudioContext, | ||
| options: &ConstantSourceOptions, | ||
| ) -> Fallible<DomRoot<ConstantSourceNode>> { | ||
| let node = ConstantSourceNode::new_inherited(window, context, options)?; | ||
| Ok(reflect_dom_object( | ||
| Box::new(node), | ||
| window, | ||
| OscillatorNodeBinding::Wrap, | ||
| )) | ||
| } | ||
|
|
||
| pub fn Constructor( | ||
| window: &Window, | ||
| context: &BaseAudioContext, | ||
| options: &ConstantSourceOptions, | ||
| ) -> Fallible<DomRoot<ConstantSourceNode>> { | ||
| ConstantSourceNode::new(window, context, options) | ||
| } | ||
| } | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
You should use
options.offsethere.