From fddea2edd848607337443c369f983ca25b55ec81 Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Sat, 22 Jun 2019 03:53:51 +0200 Subject: [PATCH] Update the null and emscripten backends for StreamEvent API --- src/emscripten/mod.rs | 8 +++++--- src/null/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/emscripten/mod.rs b/src/emscripten/mod.rs index b828f7f..cb53729 100644 --- a/src/emscripten/mod.rs +++ b/src/emscripten/mod.rs @@ -17,6 +17,7 @@ use PauseStreamError; use PlayStreamError; use SupportedFormatsError; use StreamData; +use StreamEvent; use SupportedFormat; use UnknownTypeOutputBuffer; @@ -43,7 +44,7 @@ impl EventLoop { #[inline] pub fn run(&self, callback: F) -> ! - where F: FnMut(StreamId, StreamData) + where F: FnMut(StreamId, StreamEvent) { // The `run` function uses `set_timeout` to invoke a Rust callback repeatidely. The job // of this callback is to fill the content of the audio buffers. @@ -52,7 +53,7 @@ impl EventLoop { // and to the `callback` parameter that was passed to `run`. fn callback_fn(user_data_ptr: *mut c_void) - where F: FnMut(StreamId, StreamData) + where F: FnMut(StreamId, StreamEvent) { unsafe { let user_data_ptr2 = user_data_ptr as *mut (&EventLoop, F); @@ -71,7 +72,8 @@ impl EventLoop { { let buffer = UnknownTypeOutputBuffer::F32(::OutputBuffer { buffer: &mut temporary_buffer }); let data = StreamData::Output { buffer: buffer }; - user_cb(StreamId(stream_id), data); + let event = StreamEvent::Data(data); + user_cb(StreamId(stream_id), event); // TODO: directly use a TypedArray once this is supported by stdweb } diff --git a/src/null/mod.rs b/src/null/mod.rs index c7e4cb7..f3238c8 100644 --- a/src/null/mod.rs +++ b/src/null/mod.rs @@ -10,7 +10,7 @@ use Format; use PauseStreamError; use PlayStreamError; use SupportedFormatsError; -use StreamData; +use StreamEvent; use SupportedFormat; pub struct EventLoop; @@ -23,7 +23,7 @@ impl EventLoop { #[inline] pub fn run(&self, _callback: F) -> ! - where F: FnMut(StreamId, StreamData) + where F: FnMut(StreamId, StreamEvent) { loop { /* TODO: don't spin */ } }