mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fire AudioScheduledSourceNode.onended when playback stops
This commit is contained in:
parent
c9ff1b9f57
commit
acb03603b6
4 changed files with 37 additions and 7 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -3076,7 +3076,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#6403c703ac7411f5d3b18f5edc5889cf1cbceb09"
|
||||
source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748"
|
||||
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)",
|
||||
|
@ -3085,7 +3085,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-audio"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#6403c703ac7411f5d3b18f5edc5889cf1cbceb09"
|
||||
source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748"
|
||||
dependencies = [
|
||||
"byte-slice-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3097,13 +3097,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo-media-gstreamer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#6403c703ac7411f5d3b18f5edc5889cf1cbceb09"
|
||||
source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748"
|
||||
dependencies = [
|
||||
"byte-slice-cast 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer-app 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gstreamer-audio 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-media-audio 0.1.0 (git+https://github.com/servo/media)",
|
||||
"zip 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3204,7 +3203,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servo_media_derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/media#6403c703ac7411f5d3b18f5edc5889cf1cbceb09"
|
||||
source = "git+https://github.com/servo/media#d08d03f9b78827cc1516d8a3b8e94ffc9394c748"
|
||||
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)",
|
||||
|
|
|
@ -19,6 +19,7 @@ datetime-local
|
|||
dir
|
||||
email
|
||||
emptied
|
||||
ended
|
||||
error
|
||||
fantasy
|
||||
fetch
|
||||
|
|
|
@ -16,8 +16,8 @@ use js::rust::CustomAutoRooterGuard;
|
|||
use js::typedarray::{CreateWith, Float32Array};
|
||||
use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer;
|
||||
use std::cmp::min;
|
||||
use std::ptr::{self, NonNull};
|
||||
use std::mem;
|
||||
use std::ptr::{self, NonNull};
|
||||
|
||||
type JSAudioChannel = Heap<*mut JSObject>;
|
||||
|
||||
|
|
|
@ -6,10 +6,15 @@ use dom::baseaudiocontext::BaseAudioContext;
|
|||
use dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions;
|
||||
use dom::bindings::codegen::Bindings::AudioScheduledSourceNodeBinding::AudioScheduledSourceNodeMethods;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_media::audio::node::{AudioNodeMessage, AudioNodeInit, AudioScheduledSourceNodeMessage};
|
||||
use servo_media::audio::node::OnEndedCallback;
|
||||
use std::cell::Cell;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct AudioScheduledSourceNode {
|
||||
|
@ -51,7 +56,6 @@ impl AudioScheduledSourceNode {
|
|||
|
||||
impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
|
||||
// XXX We should dispatch this when we reach the end. Depends on servo-media #82.
|
||||
event_handler!(ended, GetOnended, SetOnended);
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
|
||||
|
@ -59,6 +63,32 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
|
|||
if self.started.get() || self.stopped.get() {
|
||||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
let this = Trusted::new(self);
|
||||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
let task_source = window.dom_manipulation_task_source();
|
||||
let canceller = window.task_canceller(TaskSourceName::DOMManipulation);
|
||||
let callback = OnEndedCallback::new(move || {
|
||||
let _ = task_source.queue_with_canceller(
|
||||
task!(ended: move || {
|
||||
let this = this.root();
|
||||
let global = this.global();
|
||||
let window = global.as_window();
|
||||
window.dom_manipulation_task_source().queue_simple_event(
|
||||
this.upcast(),
|
||||
atom!("ended"),
|
||||
&window
|
||||
);
|
||||
}),
|
||||
&canceller,
|
||||
);
|
||||
});
|
||||
|
||||
self.node().message(
|
||||
AudioNodeMessage::AudioScheduledSourceNode(
|
||||
AudioScheduledSourceNodeMessage::RegisterOnEndedCallback(callback)));
|
||||
|
||||
self.started.set(true);
|
||||
self.node
|
||||
.message(AudioNodeMessage::AudioScheduledSourceNode(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue