prepareToPlay and processBlock thread-safety

For the record.
I think I am seeing Nuendo (DOP and live) instances call prepareToPlay while procesBlock is running. So it calls it once, then audio processing starts, then it calls it again a few buffer later. So there’s a good chance I’m gonna set things in prepareToPlay while they are being used in processBlock().

prepareToPlay() is our only opportunity to set up filters, prepare them and reset() after setting the filter order (as is required). So this race condition is basically unavoidable unless we add a mutex/lock used by these 2 callbacks.

That’s working but we did just stick a lock in the audio callback. In 99.9% of cases prepareToPlay will never cause the audio thread to lock… and if it does it’s because Steinberg are being naughty. Right?

I’m trying to convince myself this is all OK.