Test OscillatorNode with servo_media

This commit is contained in:
Fernando Jiménez Moreno 2018-03-26 19:04:33 +02:00
parent e9c40665ba
commit d8365111c9
5 changed files with 26 additions and 2 deletions

View file

@ -87,7 +87,7 @@ servo_arc = {path = "../servo_arc"}
servo_atoms = {path = "../atoms"}
servo_config = {path = "../config"}
servo_geometry = {path = "../geometry" }
servo_media = {git = "https://github.com/ferjm/media"}
servo_media = {path = "../../../media/servo-media"}
servo_rand = {path = "../rand"}
servo_url = {path = "../url"}
smallvec = "0.6"

View file

@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioSche
use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
use dom::bindings::num::Finite;
use dom_struct::dom_struct;
use servo_media::ServoMedia;
#[dom_struct]
pub struct AudioScheduledSourceNode {
@ -30,6 +31,18 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
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

View file

@ -7,11 +7,13 @@ use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation};
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextMethods;
use dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState;
use dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorOptions;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::root::DomRoot;
use dom::globalscope::GlobalScope;
use dom::promise::Promise;
use dom::oscillatornode::OscillatorNode;
use dom_struct::dom_struct;
use std::rc::Rc;
@ -76,4 +78,12 @@ impl BaseAudioContextMethods for BaseAudioContext {
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
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)
}
}

View file

@ -48,7 +48,7 @@ interface BaseAudioContext : EventTarget {
// ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
// ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
// DynamicsCompressorNode createDynamicsCompressor();
// OscillatorNode createOscillator();
OscillatorNode createOscillator();
// PeriodicWave createPeriodicWave(sequence<float> real,
// sequence<float> imag,
// optional PeriodicWaveConstraints constraints);

View file

@ -86,6 +86,7 @@ extern crate servo_arc;
#[macro_use] extern crate servo_atoms;
extern crate servo_config;
extern crate servo_geometry;
extern crate servo_media;
extern crate servo_rand;
extern crate servo_url;
extern crate smallvec;