web-audio-api-rs icon indicating copy to clipboard operation
web-audio-api-rs copied to clipboard

Implement `BaseAudioContext.state`

Open orottier opened this issue 3 years ago • 2 comments
trafficstars

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)

orottier avatar Jan 22 '22 10:01 orottier

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)

orottier avatar Jan 23 '22 14:01 orottier

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

orottier avatar Mar 20 '22 10:03 orottier