Skip to content

AudioParam automationRate does not instantly update on the control thread #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orottier opened this issue Jan 4, 2024 · 1 comment · Fixed by #428
Closed

AudioParam automationRate does not instantly update on the control thread #426

orottier opened this issue Jan 4, 2024 · 1 comment · Fixed by #428

Comments

@orottier
Copy link
Owner

orottier commented Jan 4, 2024

The following test fails:

#[test]
fn test_automation_rate_synchronicity() {
    let context = OfflineAudioContext::new(1, 0, 48000.);

    let opts = AudioParamDescriptor {
        name: String::new(),
        automation_rate: AutomationRate::A, // start with A
        default_value: 0.,
        min_value: 0.,
        max_value: 1.,
    };
    let (param, _render) = audio_param_pair(opts, context.mock_registration());

    // set to K
    param.set_automation_rate(AutomationRate::K);
    assert_eq!(param.automation_rate(), AutomationRate::K);
}

This is quite tricky to fix. We could keep a local copy of the automation rate on the control thread, but because these methods all take &self it needs to be wrapped in an atomic and is susceptible to data races on concurrent calls. Best would be to require &mut on the methods but it is incompatible with how we return AudioParams from the AudioNodes (and the Clone impl)

@orottier
Copy link
Owner Author

orottier commented Jan 4, 2024

A Mutex could resolve this issue, when we hold the lock while sending the control message to the render thread. A bit ugly though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant