webaudio: expose AudioContext in WebAudioStream (#659)

This commit is contained in:
Rodrigo Batista de Moraes 2022-04-25 22:21:41 -03:00 • committed by GitHub
parent 8d164ed585
commit b1457e5945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -350,6 +350,14 @@ impl DeviceTrait for Device {
} }
} }
impl Stream {
/// Return the [`AudioContext`](https://developer.mozilla.org/docs/Web/API/AudioContext) used
/// by this stream.
pub fn audio_context(&self) -> &AudioContext {
&*self.ctx
}
}
impl StreamTrait for Stream { impl StreamTrait for Stream {
fn play(&self) -> Result<(), PlayStreamError> { fn play(&self) -> Result<(), PlayStreamError> {
let window = web_sys::window().unwrap(); let window = web_sys::window().unwrap();