Update the null and emscripten backends for StreamEvent API
This commit is contained in:
parent
3e3cf26cde
commit
fddea2edd8
|
@ -17,6 +17,7 @@ use PauseStreamError;
|
||||||
use PlayStreamError;
|
use PlayStreamError;
|
||||||
use SupportedFormatsError;
|
use SupportedFormatsError;
|
||||||
use StreamData;
|
use StreamData;
|
||||||
|
use StreamEvent;
|
||||||
use SupportedFormat;
|
use SupportedFormat;
|
||||||
use UnknownTypeOutputBuffer;
|
use UnknownTypeOutputBuffer;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ impl EventLoop {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn run<F>(&self, callback: F) -> !
|
pub fn run<F>(&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
|
// 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.
|
// 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`.
|
// and to the `callback` parameter that was passed to `run`.
|
||||||
|
|
||||||
fn callback_fn<F>(user_data_ptr: *mut c_void)
|
fn callback_fn<F>(user_data_ptr: *mut c_void)
|
||||||
where F: FnMut(StreamId, StreamData)
|
where F: FnMut(StreamId, StreamEvent)
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
let user_data_ptr2 = user_data_ptr as *mut (&EventLoop, F);
|
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 buffer = UnknownTypeOutputBuffer::F32(::OutputBuffer { buffer: &mut temporary_buffer });
|
||||||
let data = StreamData::Output { buffer: 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<f32> once this is supported by stdweb
|
// TODO: directly use a TypedArray<f32> once this is supported by stdweb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Format;
|
||||||
use PauseStreamError;
|
use PauseStreamError;
|
||||||
use PlayStreamError;
|
use PlayStreamError;
|
||||||
use SupportedFormatsError;
|
use SupportedFormatsError;
|
||||||
use StreamData;
|
use StreamEvent;
|
||||||
use SupportedFormat;
|
use SupportedFormat;
|
||||||
|
|
||||||
pub struct EventLoop;
|
pub struct EventLoop;
|
||||||
|
@ -23,7 +23,7 @@ impl EventLoop {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn run<F>(&self, _callback: F) -> !
|
pub fn run<F>(&self, _callback: F) -> !
|
||||||
where F: FnMut(StreamId, StreamData)
|
where F: FnMut(StreamId, StreamEvent)
|
||||||
{
|
{
|
||||||
loop { /* TODO: don't spin */ }
|
loop { /* TODO: don't spin */ }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue