diff --git a/src/lib.rs b/src/lib.rs index 74405a4a2..bd7e1d709 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -332,6 +332,7 @@ pub struct Data { /// | wasapi | `QueryPerformanceCounter` | /// | asio | `timeGetTime` | /// | emscripten | `AudioContext.getOutputTimestamp` | +#[cfg_attr(target_os = "emscripten", wasm_bindgen)] #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] pub struct StreamInstant { secs: i64, @@ -339,6 +340,7 @@ pub struct StreamInstant { } /// A timestamp associated with a call to an input stream's data callback. +#[cfg_attr(target_os = "emscripten", wasm_bindgen)] #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] pub struct InputStreamTimestamp { /// The instant the stream's data callback was invoked. @@ -350,6 +352,7 @@ pub struct InputStreamTimestamp { } /// A timestamp associated with a call to an output stream's data callback. +#[cfg_attr(target_os = "emscripten", wasm_bindgen)] #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] pub struct OutputStreamTimestamp { /// The instant the stream's data callback was invoked. @@ -479,12 +482,16 @@ impl StreamInstant { Self::new(s, ns) } - fn new(secs: i64, nanos: u32) -> Self { + pub fn new(secs: i64, nanos: u32) -> Self { StreamInstant { secs, nanos } } } impl InputCallbackInfo { + pub fn new(timestamp: InputStreamTimestamp) -> Self { + Self { timestamp } + } + /// The timestamp associated with the call to an input stream's data callback. pub fn timestamp(&self) -> InputStreamTimestamp { self.timestamp @@ -492,6 +499,10 @@ impl InputCallbackInfo { } impl OutputCallbackInfo { + pub fn new(timestamp: OutputStreamTimestamp) -> Self { + Self { timestamp } + } + /// The timestamp associated with the call to an output stream's data callback. pub fn timestamp(&self) -> OutputStreamTimestamp { self.timestamp