mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Test OscillatorNode with servo_media
This commit is contained in:
parent
e9c40665ba
commit
d8365111c9
5 changed files with 26 additions and 2 deletions
|
@ -87,7 +87,7 @@ servo_arc = {path = "../servo_arc"}
|
||||||
servo_atoms = {path = "../atoms"}
|
servo_atoms = {path = "../atoms"}
|
||||||
servo_config = {path = "../config"}
|
servo_config = {path = "../config"}
|
||||||
servo_geometry = {path = "../geometry" }
|
servo_geometry = {path = "../geometry" }
|
||||||
servo_media = {git = "https://github.com/ferjm/media"}
|
servo_media = {path = "../../../media/servo-media"}
|
||||||
servo_rand = {path = "../rand"}
|
servo_rand = {path = "../rand"}
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
smallvec = "0.6"
|
smallvec = "0.6"
|
||||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioSche
|
||||||
use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
|
use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
use servo_media::ServoMedia;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AudioScheduledSourceNode {
|
pub struct AudioScheduledSourceNode {
|
||||||
|
@ -30,6 +31,18 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
|
||||||
|
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
|
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
|
||||||
fn Start(&self, _when: Finite<f64>) {
|
fn Start(&self, _when: Finite<f64>) {
|
||||||
|
// XXX This is just here to test servo_media from servo.
|
||||||
|
// ServoMedia needs to expose a way to feed the audio stream and
|
||||||
|
// we need to implement all the AudioContext logic to connect
|
||||||
|
// AudioNodes.
|
||||||
|
match ServoMedia::get().get_audio_stream() {
|
||||||
|
Ok(stream) => {
|
||||||
|
stream.play();
|
||||||
|
},
|
||||||
|
Err(_) => {
|
||||||
|
println!("OH NOES");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
|
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
|
||||||
|
|
|
@ -7,11 +7,13 @@ use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
|
||||||
use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation};
|
use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation};
|
||||||
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextMethods;
|
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextMethods;
|
||||||
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState;
|
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState;
|
||||||
|
use dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorOptions;
|
||||||
use dom::bindings::num::Finite;
|
use dom::bindings::num::Finite;
|
||||||
use dom::bindings::reflector::{DomObject, Reflector};
|
use dom::bindings::reflector::{DomObject, Reflector};
|
||||||
use dom::bindings::root::DomRoot;
|
use dom::bindings::root::DomRoot;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::promise::Promise;
|
use dom::promise::Promise;
|
||||||
|
use dom::oscillatornode::OscillatorNode;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -76,4 +78,12 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
|
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
|
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
|
||||||
event_handler!(statechange, GetOnstatechange, SetOnstatechange);
|
event_handler!(statechange, GetOnstatechange, SetOnstatechange);
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
fn CreateOscillator(&self) -> DomRoot<OscillatorNode> {
|
||||||
|
let global = self.global();
|
||||||
|
let window = global.as_window();
|
||||||
|
let options = unsafe { OscillatorOptions::empty(window.get_cx()) };
|
||||||
|
OscillatorNode::new(&window, &self, &options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ interface BaseAudioContext : EventTarget {
|
||||||
// ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
|
// ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
|
||||||
// ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
|
// ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
|
||||||
// DynamicsCompressorNode createDynamicsCompressor();
|
// DynamicsCompressorNode createDynamicsCompressor();
|
||||||
// OscillatorNode createOscillator();
|
OscillatorNode createOscillator();
|
||||||
// PeriodicWave createPeriodicWave(sequence<float> real,
|
// PeriodicWave createPeriodicWave(sequence<float> real,
|
||||||
// sequence<float> imag,
|
// sequence<float> imag,
|
||||||
// optional PeriodicWaveConstraints constraints);
|
// optional PeriodicWaveConstraints constraints);
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern crate servo_arc;
|
||||||
#[macro_use] extern crate servo_atoms;
|
#[macro_use] extern crate servo_atoms;
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
extern crate servo_geometry;
|
extern crate servo_geometry;
|
||||||
|
extern crate servo_media;
|
||||||
extern crate servo_rand;
|
extern crate servo_rand;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue