Host parameters getting set from multiple threads?

I have a JUCE plugin that handles host parameters using the juce::AudioProcessorParameterGroup machinery. I was assuming that hosts always set parameters on the audio thread, and therefore I haven’t added any thread synchronisation between host parameters and audio processing.

Now my plug-in crashes auval validation on macOS, if I use the -stress option there. Turns out that in this case, auval tries to set host parameters from three different threads simultaneously, while doing audio processing on the fourth thread. This causes a race condition.

Question: are there hosts out there that actually do this? Does this need to be accounted for? Do I need to fix those race conditions?

Hosts will definitely set parameters from the message thread and audio threads concurrently. Image the case where automation is being read (this will usually get passed on the audio thread) and then they turn a parameter knob in the UI (this will usually go via the message thread).

So yes, you will probably have to be able to deal with this.

and from a 3rd thread if your name is Protools if I remember correctly.

Could you explain this a bit further? It’s safe to set a parameter from our GUI - we have a FIFO to pipe these changes to the audio thread safely.

What wouldn’t be safe (for us) is if the host calls AudioProcessorParameter::setValue() directly from a thread that’s not the audio thread. Are you suggesting they’d do that?

Yes, they’d definitely do that. Image the host is showing some generic slider for the plugin, either in a generic interface (I think Logic and Reaper do this) or as a list e.g. in Waveform:

These changes from host UI controls tend to get passed in via AudioProcessorParameter::setValue(). The host might not even be running the audio engine when these kind of changes happen so processBlock and the audio thread won’t be called.

1 Like

Ah I hadn’t thought about the generic UI. We’ll have to think carefully about how to deal with this, then. Thanks for the info!