web-audio-api-rs
web-audio-api-rs copied to clipboard
Implement `BaseAudioContext.state`
https://www.w3.org/TR/webaudio/#dom-baseaudiocontext-control-thread-state-slot
Before we think about also adding onStateChange handlers ( https://www.w3.org/TR/webaudio/#dom-baseaudiocontext-onstatechange ) we need to think about the architecture for event handling (probably in a separate issue)
Once this is implemented, we can fix the panic that occurs when you add nodes to a closed context, e.g.
let context = AudioContext::new(None);
context.close();
let delay = context.create_delay(1.);
The panic occurs because we attempt to use the closed message channel to the render thread.
As per discussion in https://github.com/WebAudio/web-audio-api/issues/1580, creating nodes on a closed context should not throw an exception (but will also not do anything useful)
Another panic that can be fixed is
let context = AudioContext::new(None);
let analyser = context.create_analyser();
context.close();
analyser.get_float_time_domain_data(vec![1.; 128]);
This should just return zeroes when the context is paused/closed