From a29a54616d7bf1a44bd9919c2e098302352763fd Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 22:23:19 +0530 Subject: [PATCH 1/8] Update servo-media --- Cargo.lock | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9c0b5fab7ef..115083e664c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,6 +261,11 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "boxfnonce" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "brotli" version = "1.1.2" @@ -3274,7 +3279,7 @@ dependencies = [ [[package]] name = "servo-media" version = "0.1.0" -source = "git+https://github.com/servo/media#f52c1c677a757cb8435d9e4c77680473d32c4aab" +source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" dependencies = [ "servo-media-audio 0.1.0 (git+https://github.com/servo/media)", "servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)", @@ -3284,12 +3289,15 @@ dependencies = [ [[package]] name = "servo-media-audio" version = "0.1.0" -source = "git+https://github.com/servo/media#f52c1c677a757cb8435d9e4c77680473d32c4aab" +source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" dependencies = [ + "boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "servo_media_derive 0.1.0 (git+https://github.com/servo/media)", "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3297,7 +3305,7 @@ dependencies = [ [[package]] name = "servo-media-gstreamer" version = "0.1.0" -source = "git+https://github.com/servo/media#f52c1c677a757cb8435d9e4c77680473d32c4aab" +source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" dependencies = [ "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3315,7 +3323,7 @@ dependencies = [ [[package]] name = "servo-media-player" version = "0.1.0" -source = "git+https://github.com/servo/media#f52c1c677a757cb8435d9e4c77680473d32c4aab" +source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" dependencies = [ "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3410,7 +3418,7 @@ dependencies = [ [[package]] name = "servo_media_derive" version = "0.1.0" -source = "git+https://github.com/servo/media#f52c1c677a757cb8435d9e4c77680473d32c4aab" +source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" dependencies = [ "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4350,6 +4358,7 @@ dependencies = [ "checksum blurmac 0.1.0 (git+https://github.com/servo/devices)" = "" "checksum blurmock 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "68dd72da3a3bb40f3d3bdd366c4cf8e2b1d208c366304f382c80cef8126ca8da" "checksum blurz 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e73bda0f4c71c63a047351070097f3f507e6718e86b9ee525173371ef7b94b73" +"checksum boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbec60c560f322d8e3cd403f91d8908cfd965fff53ba97154bd1b9d90149d98e" "checksum brotli 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fe87b40996b84fdc56e57c165d93079f4b50cb806598118e692ddfaa3d3c57c0" "checksum brotli-decompressor 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "313f4b6cc0b365d6b88eda5aa40175ee34ac6efa9a79e0b3b8202eca90247ba8" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" From 18b9ad9e5c978a2e218673d992d8c36a90780e1a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 13:47:38 +0530 Subject: [PATCH 2/8] AnalyserNode in script --- components/script/dom/analysernode.rs | 218 ++++++++++++++++++ components/script/dom/bindings/trace.rs | 3 +- components/script/dom/mod.rs | 1 + .../script/dom/webidls/AnalyserNode.webidl | 28 +++ 4 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 components/script/dom/analysernode.rs create mode 100644 components/script/dom/webidls/AnalyserNode.webidl diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs new file mode 100644 index 000000000000..50951021c430 --- /dev/null +++ b/components/script/dom/analysernode.rs @@ -0,0 +1,218 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + +use dom::audionode::AudioNode; +use dom::baseaudiocontext::BaseAudioContext; +use dom::bindings::cell::DomRefCell; +use dom::bindings::codegen::Bindings::AnalyserNodeBinding::{self, AnalyserNodeMethods, AnalyserOptions}; +use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation}; +use dom::bindings::error::{Error, Fallible}; +use dom::bindings::num::Finite; +use dom::bindings::refcounted::Trusted; +use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; +use dom::window::Window; +use dom_struct::dom_struct; +use ipc_channel::ipc::{self, IpcReceiver}; +use ipc_channel::router::ROUTER; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::{Float32Array, Uint8Array}; +use servo_media::audio::analyser_node::AnalysisEngine; +use servo_media::audio::block::Block; +use servo_media::audio::node::AudioNodeInit; +use task_source::{TaskSource, TaskSourceName}; + +#[dom_struct] +pub struct AnalyserNode { + node: AudioNode, + #[ignore_malloc_size_of = "Defined in servo-media"] + engine: DomRefCell, +} + +impl AnalyserNode { + #[allow(unrooted_must_root)] + pub fn new_inherited( + _: &Window, + context: &BaseAudioContext, + options: &AnalyserOptions, + ) -> Fallible<(AnalyserNode, IpcReceiver)> { + let node_options = options.parent + .unwrap_or(1, ChannelCountMode::Max, + ChannelInterpretation::Speakers); + + if options.fftSize > 32768 || options.fftSize < 32 || + (options.fftSize & (options.fftSize - 1) != 0) { + return Err(Error::IndexSize) + } + + if *options.maxDecibels <= *options.minDecibels { + return Err(Error::IndexSize) + } + + if *options.smoothingTimeConstant < 0. || *options.smoothingTimeConstant > 1. { + return Err(Error::IndexSize); + } + + let (send, rcv) = ipc::channel().unwrap(); + let callback = move |block| { + send.send(block).unwrap(); + }; + + let node = AudioNode::new_inherited( + AudioNodeInit::AnalyserNode(Box::new(callback)), + context, + node_options, + 1, // inputs + 1, // outputs + )?; + + + let engine = AnalysisEngine::new(options.fftSize as usize, + *options.smoothingTimeConstant, + *options.minDecibels, *options.maxDecibels); + Ok((AnalyserNode { + node, + engine: DomRefCell::new(engine) + }, rcv)) + } + + #[allow(unrooted_must_root)] + pub fn new( + window: &Window, + context: &BaseAudioContext, + options: &AnalyserOptions, + ) -> Fallible> { + let (node, recv) = AnalyserNode::new_inherited(window, context, options)?; + let object = reflect_dom_object(Box::new(node), window, AnalyserNodeBinding::Wrap); + let source = window.dom_manipulation_task_source(); + let canceller = window.task_canceller(TaskSourceName::DOMManipulation); + let this = Trusted::new(&*object); + + ROUTER.add_route(recv.to_opaque(), Box::new(move |block| { + let this = this.clone(); + let _ = source.queue_with_canceller(task!(append_analysis_block: move || { + let this = this.root(); + this.push_block(block.to().unwrap()) + }), &canceller); + })); + Ok(object) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-analysernode + pub fn Constructor( + window: &Window, + context: &BaseAudioContext, + options: &AnalyserOptions, + ) -> Fallible> { + AnalyserNode::new(window, context, options) + } + + pub fn push_block(&self, block: Block) { + self.engine.borrow_mut().push(block) + } +} + +impl AnalyserNodeMethods for AnalyserNode { + #[allow(unsafe_code)] + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-getfloatfrequencydata + fn GetFloatFrequencyData(&self, mut array: CustomAutoRooterGuard) { + // Invariant to maintain: No JS code that may touch the array should + // run whilst we're writing to it + let dest = unsafe { array.as_mut_slice() }; + self.engine.borrow_mut().fill_frequency_data(dest); + } + + #[allow(unsafe_code)] + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-getbytefrequencydata + fn GetByteFrequencyData(&self, mut array: CustomAutoRooterGuard) { + // Invariant to maintain: No JS code that may touch the array should + // run whilst we're writing to it + let dest = unsafe { array.as_mut_slice() }; + self.engine.borrow_mut().fill_byte_frequency_data(dest); + + } + + #[allow(unsafe_code)] + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-getfloattimedomaindata + fn GetFloatTimeDomainData(&self, mut array: CustomAutoRooterGuard) { + // Invariant to maintain: No JS code that may touch the array should + // run whilst we're writing to it + let dest = unsafe { array.as_mut_slice() }; + self.engine.borrow().fill_time_domain_data(dest); + + } + + #[allow(unsafe_code)] + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-getbytetimedomaindata + fn GetByteTimeDomainData(&self, mut array: CustomAutoRooterGuard) { + // Invariant to maintain: No JS code that may touch the array should + // run whilst we're writing to it + let dest = unsafe { array.as_mut_slice() }; + self.engine.borrow().fill_byte_time_domain_data(dest); + + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-fftsize + fn SetFftSize(&self, value: u32) -> Fallible<()> { + if value > 32768 || value < 32 || + (value & (value - 1) != 0) { + return Err(Error::IndexSize) + } + self.engine.borrow_mut().set_fft_size(value as usize); + Ok(()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-fftsize + fn FftSize(&self) -> u32 { + self.engine.borrow().get_fft_size() as u32 + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-frequencybincount + fn FrequencyBinCount(&self) -> u32 { + self.FftSize() / 2 + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-mindecibels + fn MinDecibels(&self) -> Finite { + Finite::wrap(self.engine.borrow().get_min_decibels()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-mindecibels + fn SetMinDecibels(&self, value: Finite) -> Fallible<()> { + if *value >= self.engine.borrow().get_max_decibels() { + return Err(Error::IndexSize) + } + self.engine.borrow_mut().set_min_decibels(*value); + Ok(()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-maxdecibels + fn MaxDecibels(&self) -> Finite { + Finite::wrap(self.engine.borrow().get_max_decibels()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-maxdecibels + fn SetMaxDecibels(&self, value: Finite) -> Fallible<()> { + if *value <= self.engine.borrow().get_min_decibels() { + return Err(Error::IndexSize) + } + self.engine.borrow_mut().set_max_decibels(*value); + Ok(()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-smoothingtimeconstant + fn SmoothingTimeConstant(&self) -> Finite { + Finite::wrap(self.engine.borrow().get_smoothing_constant()) + } + + /// https://webaudio.github.io/web-audio-api/#dom-analysernode-smoothingtimeconstant + fn SetSmoothingTimeConstant(&self, value: Finite) -> Fallible<()> { + if *value < 0. || *value > 1. { + return Err(Error::IndexSize) + } + self.engine.borrow_mut().set_smoothing_constant(*value); + Ok(()) + } +} + diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 33cd3e02b55a..ca01ff600d83 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -90,6 +90,7 @@ use servo_arc::Arc as ServoArc; use servo_atoms::Atom; use servo_channel::{Receiver, Sender}; use servo_media::Backend; +use servo_media::audio::analyser_node::AnalysisEngine; use servo_media::audio::buffer_source_node::AudioBuffer; use servo_media::audio::context::AudioContext; use servo_media::audio::graph::NodeId; @@ -435,7 +436,7 @@ unsafe_no_jsmanaged_fields!(SourceSet); unsafe_no_jsmanaged_fields!(AudioBuffer); unsafe_no_jsmanaged_fields!(AudioContext); unsafe_no_jsmanaged_fields!(NodeId); -unsafe_no_jsmanaged_fields!(DistanceModel, PanningModel, ParamType); +unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType); unsafe impl<'a> JSTraceable for &'a str { #[inline] diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 04a234a80d3d..54b9adcc4225 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -215,6 +215,7 @@ pub mod types { pub mod abstractworker; pub mod abstractworkerglobalscope; pub mod activation; +pub mod analysernode; pub mod attr; pub mod audiobuffer; pub mod audiobuffersourcenode; diff --git a/components/script/dom/webidls/AnalyserNode.webidl b/components/script/dom/webidls/AnalyserNode.webidl new file mode 100644 index 000000000000..b9b04ab487c4 --- /dev/null +++ b/components/script/dom/webidls/AnalyserNode.webidl @@ -0,0 +1,28 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ +/* + * The origin of this IDL file is + * https://webaudio.github.io/web-audio-api/#analysernode + */ + +dictionary AnalyserOptions : AudioNodeOptions { + unsigned long fftSize = 2048; + double maxDecibels = -30; + double minDecibels = -100; + double smoothingTimeConstant = 0.8; +}; + +[Exposed=Window, + Constructor (BaseAudioContext context, optional AnalyserOptions options)] +interface AnalyserNode : AudioNode { + void getFloatFrequencyData (Float32Array array); + void getByteFrequencyData (Uint8Array array); + void getFloatTimeDomainData (Float32Array array); + void getByteTimeDomainData (Uint8Array array); + [SetterThrows] attribute unsigned long fftSize; + readonly attribute unsigned long frequencyBinCount; + [SetterThrows] attribute double minDecibels; + [SetterThrows] attribute double maxDecibels; + [SetterThrows] attribute double smoothingTimeConstant; +}; From aa2ccb38ca956401f57617b11be0b688b1bf7bb4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 16:30:59 +0530 Subject: [PATCH 3/8] Update WPT expectations --- .../webaudio/idlharness.https.window.js.ini | 159 ------------------ .../ctor-analyser.html.ini | 16 +- .../test-analysernode.html.ini | 3 - 3 files changed, 15 insertions(+), 163 deletions(-) diff --git a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini index 4114b54f0a6f..c02b11746d7e 100644 --- a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini @@ -224,165 +224,6 @@ [AudioParam interface: calling setValueCurveAtTime([object Object\], double, double) on new AudioBufferSourceNode(context).playbackRate with too few arguments must throw TypeError] expected: FAIL - [AnalyserNode interface: existence and properties of interface object] - expected: FAIL - - [AnalyserNode interface object length] - expected: FAIL - - [AnalyserNode interface object name] - expected: FAIL - - [AnalyserNode interface: existence and properties of interface prototype object] - expected: FAIL - - [AnalyserNode interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [AnalyserNode interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [AnalyserNode interface: operation getFloatFrequencyData(Float32Array)] - expected: FAIL - - [AnalyserNode interface: operation getByteFrequencyData(Uint8Array)] - expected: FAIL - - [AnalyserNode interface: operation getFloatTimeDomainData(Float32Array)] - expected: FAIL - - [AnalyserNode interface: operation getByteTimeDomainData(Uint8Array)] - expected: FAIL - - [AnalyserNode interface: attribute fftSize] - expected: FAIL - - [AnalyserNode interface: attribute frequencyBinCount] - expected: FAIL - - [AnalyserNode interface: attribute minDecibels] - expected: FAIL - - [AnalyserNode interface: attribute maxDecibels] - expected: FAIL - - [AnalyserNode interface: attribute smoothingTimeConstant] - expected: FAIL - - [AnalyserNode must be primary interface of new AnalyserNode(context)] - expected: FAIL - - [Stringification of new AnalyserNode(context)] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatFrequencyData(Float32Array)" with the proper type] - expected: FAIL - - [AnalyserNode interface: calling getFloatFrequencyData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteFrequencyData(Uint8Array)" with the proper type] - expected: FAIL - - [AnalyserNode interface: calling getByteFrequencyData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatTimeDomainData(Float32Array)" with the proper type] - expected: FAIL - - [AnalyserNode interface: calling getFloatTimeDomainData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteTimeDomainData(Uint8Array)" with the proper type] - expected: FAIL - - [AnalyserNode interface: calling getByteTimeDomainData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "fftSize" with the proper type] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "frequencyBinCount" with the proper type] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "minDecibels" with the proper type] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "maxDecibels" with the proper type] - expected: FAIL - - [AnalyserNode interface: new AnalyserNode(context) must inherit property "smoothingTimeConstant" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioNode, unsigned long, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling connect(AudioNode, unsigned long, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioParam, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling connect(AudioParam, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect()" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioParam) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioParam, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "context" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "numberOfInputs" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "numberOfOutputs" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "channelCount" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "channelCountMode" with the proper type] - expected: FAIL - - [AudioNode interface: new AnalyserNode(context) must inherit property "channelInterpretation" with the proper type] - expected: FAIL - [AudioListener interface: operation setPosition(float, float, float)] expected: FAIL diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini index decbfc1cb82c..5f2600f8dd69 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini @@ -1,5 +1,19 @@ [ctor-analyser.html] - expected: ERROR [X node0 = new AnalyserNode(context) incorrectly threw TypeError: "window[name\] is not a constructor".] expected: FAIL + [X node0.channelCount is not equal to 1. Got 2.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 7 tasks were failed.] + expected: FAIL + + [< [default constructor\] 2 out of 12 assertions were failed.] + expected: FAIL + + [X node0.smoothingTimeConstant is not equal to 0.8. Got 0.800000011920929.] + expected: FAIL + + [< [default constructor\] 1 out of 12 assertions were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini index 6992ca5707d1..3628d39c5cc9 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini @@ -1,7 +1,4 @@ [test-analysernode.html] - [Test AnalyserNode's ctor API] - expected: FAIL - [Test AnalyserNode API] expected: FAIL From 9dfc57878ecac962b8a953cbb5fa422aa41ae0ba Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 16:31:11 +0530 Subject: [PATCH 4/8] Add createAnalyser --- components/script/dom/baseaudiocontext.rs | 7 +++++++ components/script/dom/webidls/BaseAudioContext.webidl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index dbd821b64fe2..514a51f113be 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::analysernode::AnalyserNode; use dom::audiobuffer::AudioBuffer; use dom::audiobuffersourcenode::AudioBufferSourceNode; use dom::audiodestinationnode::AudioDestinationNode; @@ -9,6 +10,7 @@ use dom::audiolistener::AudioListener; use dom::audionode::MAX_CHANNEL_COUNT; use dom::bindings::callback::ExceptionHandling; use dom::bindings::cell::DomRefCell; +use dom::bindings::codegen::Bindings::AnalyserNodeBinding::AnalyserOptions; use dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation}; use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; @@ -337,6 +339,11 @@ impl BaseAudioContextMethods for BaseAudioContext { PannerNode::new(&self.global().as_window(), &self, &PannerOptions::empty()) } + /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createanalyser + fn CreateAnalyser(&self) -> Fallible> { + AnalyserNode::new(&self.global().as_window(), &self, &AnalyserOptions::empty()) + } + /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger fn CreateChannelMerger(&self, count: u32) -> Fallible> { let mut opts = ChannelMergerOptions::empty(); diff --git a/components/script/dom/webidls/BaseAudioContext.webidl b/components/script/dom/webidls/BaseAudioContext.webidl index f8b85007a649..9b8d8c5efa1d 100644 --- a/components/script/dom/webidls/BaseAudioContext.webidl +++ b/components/script/dom/webidls/BaseAudioContext.webidl @@ -35,7 +35,7 @@ interface BaseAudioContext : EventTarget { // ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0, // optional unsigned long numberOfInputChannels = 2, // optional unsigned long numberOfOutputChannels = 2); - // AnalyserNode createAnalyser(); + [Throws] AnalyserNode createAnalyser(); [Throws] GainNode createGain(); // DelayNode createDelay(optional double maxDelayTime = 1); // BiquadFilterNode createBiquadFilter(); From ed12e8dc49a024282cb7a2c0160b444bba417893 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 17:27:29 +0530 Subject: [PATCH 5/8] Update WPT expectations --- .../realtimeanalyser-basic.html.ini | 2 -- .../realtimeanalyser-fft-scaling.html.ini | 2 +- .../realtimeanalyser-fft-sizing.html.ini | 2 -- .../the-analysernode-interface/test-analyser-scale.html.ini | 4 ---- .../the-analysernode-interface/test-analysernode.html.ini | 4 ---- 5 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html.ini delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html.ini delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html.ini delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html.ini deleted file mode 100644 index f48362f4d5cb..000000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[realtimeanalyser-basic.html] - expected: ERROR diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-scaling.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-scaling.html.ini index 75d8cd648df4..dfc61af48f01 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-scaling.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-scaling.html.ini @@ -1,2 +1,2 @@ [realtimeanalyser-fft-scaling.html] - expected: ERROR + expected: TIMEOUT diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html.ini deleted file mode 100644 index 6e6b8e650d1d..000000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[realtimeanalyser-fft-sizing.html] - expected: ERROR diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html.ini deleted file mode 100644 index 856164195375..000000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[test-analyser-scale.html] - [Test AnalyserNode when the input is scaled] - expected: FAIL - diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini deleted file mode 100644 index 3628d39c5cc9..000000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[test-analysernode.html] - [Test AnalyserNode API] - expected: FAIL - From f3efd14975b7ba9947e1e387cd4e84c50b187d3e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 18:24:37 +0530 Subject: [PATCH 6/8] Update interfaces.html --- tests/wpt/mozilla/meta/MANIFEST.json | 2 +- tests/wpt/mozilla/tests/mozilla/interfaces.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index d89b2751d7f6..3388ffd25627 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -27038,7 +27038,7 @@ "testharness" ], "mozilla/interfaces.html": [ - "d48b52d06eaa76167fb8bc2c23f2410ec74ba247", + "840c233a14c3d041e43a125a6d1452670aa4fbb4", "testharness" ], "mozilla/interfaces.js": [ diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html index d48b52d06eaa..840c233a14c3 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.html +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html @@ -11,6 +11,7 @@ // IMPORTANT: Do not change the list below without review from a DOM peer! test_interfaces([ + "AnalyserNode", "Attr", "AudioBuffer", "AudioBufferSourceNode", From e9be17995226b445ec9c83b9b21d84b4c87a0838 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Sep 2018 18:29:11 +0530 Subject: [PATCH 7/8] Set default channel count for AnalyserNode to 2 This was deliberately changed (https://github.com/WebAudio/web-audio-api/pull/1397 ) but the tests have not been updated --- components/script/dom/analysernode.rs | 2 +- tests/wpt/metadata/MANIFEST.json | 4 ++-- .../ctor-analyser.html.ini | 19 ------------------- .../ctor-analyser.html | 2 +- .../test-analysernode.html | 8 ++++---- 5 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 50951021c430..27f2f27b386d 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -38,7 +38,7 @@ impl AnalyserNode { options: &AnalyserOptions, ) -> Fallible<(AnalyserNode, IpcReceiver)> { let node_options = options.parent - .unwrap_or(1, ChannelCountMode::Max, + .unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers); if options.fftSize > 32768 || options.fftSize < 32 || diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 0c1e05dbb222..5cc59d1ac9b1 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -658118,7 +658118,7 @@ "support" ], "webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html": [ - "4e27f842ddeda3e2bdd78da7b8ee3f67062d1a9f", + "a9aa4831516c6a5cefa7c8b4f67f3ef246d24777", "testharness" ], "webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html": [ @@ -658150,7 +658150,7 @@ "testharness" ], "webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html": [ - "52d3829cff3dfceef64a34669bc8e0d6e08883a9", + "a8b5a7154e94479460c1085c6b5cb584e9b6976c", "testharness" ], "webaudio/the-audio-api/the-audiobuffer-interface/.gitkeep": [ diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini deleted file mode 100644 index 5f2600f8dd69..000000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html.ini +++ /dev/null @@ -1,19 +0,0 @@ -[ctor-analyser.html] - [X node0 = new AnalyserNode(context) incorrectly threw TypeError: "window[name\] is not a constructor".] - expected: FAIL - - [X node0.channelCount is not equal to 1. Got 2.] - expected: FAIL - - [# AUDIT TASK RUNNER FINISHED: 1 out of 7 tasks were failed.] - expected: FAIL - - [< [default constructor\] 2 out of 12 assertions were failed.] - expected: FAIL - - [X node0.smoothingTimeConstant is not equal to 0.8. Got 0.800000011920929.] - expected: FAIL - - [< [default constructor\] 1 out of 12 assertions were failed.] - expected: FAIL - diff --git a/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html b/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html index 4e27f842dded..a9aa4831516c 100644 --- a/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html +++ b/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html @@ -32,7 +32,7 @@ prefix: prefix, numberOfInputs: 1, numberOfOutputs: 1, - channelCount: 1, + channelCount: 2, channelCountMode: 'max', channelInterpretation: 'speakers' }); diff --git a/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html b/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html index 52d3829cff3d..a8b5a7154e94 100644 --- a/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html +++ b/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html @@ -27,8 +27,8 @@ assert_equals( analyser.channelCount, - 1, - "analyser node has 1 input channels by default" + 2, + "analyser node has 2 input channels by default" ); assert_equals( analyser.channelCountMode, @@ -131,8 +131,8 @@ var analyser = new AnalyserNode(context); assert_equals( analyser.channelCount, - 1, - "analyser node has 1 input channels by default" + 2, + "analyser node has 2 input channels by default" ); assert_equals( analyser.channelCountMode, From cc32e12d0a78298a4ce9621bec376296eee32a2b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Sep 2018 00:09:09 +0530 Subject: [PATCH 8/8] More WPT expectation updates --- .../wpt/metadata/webaudio/idlharness.https.window.js.ini | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini index c02b11746d7e..50e3231ac0c3 100644 --- a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini @@ -8,9 +8,6 @@ [BaseAudioContext interface: attribute audioWorklet] expected: FAIL - [BaseAudioContext interface: operation createAnalyser()] - expected: FAIL - [BaseAudioContext interface: operation createBiquadFilter()] expected: FAIL @@ -92,9 +89,6 @@ [BaseAudioContext interface: context must inherit property "audioWorklet" with the proper type] expected: FAIL - [BaseAudioContext interface: context must inherit property "createAnalyser()" with the proper type] - expected: FAIL - [BaseAudioContext interface: context must inherit property "createBiquadFilter()" with the proper type] expected: FAIL @@ -161,9 +155,6 @@ [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "audioWorklet" with the proper type] expected: FAIL - [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createAnalyser()" with the proper type] - expected: FAIL - [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createBiquadFilter()" with the proper type] expected: FAIL