I’m currently implementing my own heavily simplified version of an
AudioProcessorGraph for educational purposes. One thing I haven’t been able to wrap my head around is how
AudioProcessorGraph remains thread-safe and avoids pops and clicks when modifying the graph from a non-audio thread.
For example, in the plugin host demo, it looks like connections and nodes are being freely modified from the message thread, and I’m left scratching my head as to how that safely propagates to the model used for rendering by the audio thread. There doesn’t seem to be any sort of async lock-free command queue in use (which is what I’m using in my implementation), what I see happening is the graph rendering ops list being rebuilt on the modifying thread and being swapped out on the message thread. While I can see how that works, I don’t really get how
Node objects are being safely added/removed. Is there some sort of gasp locking going on? Or are we eating race conditions?
AudioProcessorGraph is some real voodoo magic, any insight is appreciated.