AUv2 stability and thread safety - #536
Open
CrushedPixel wants to merge 5 commits into
Open
Conversation
Allow initialized rendering with nonzero host action flags. Give each input pull its own flags and clear OutputIsSilence after CLAP processing, so a silent track input cannot mark Swell's preview output as silent.
Check activate and start_processing before publishing render readiness. Return an initialization failure when either is rejected, release the adapter, and stop or deactivate only stages that actually succeeded. This prevents a failed processor from appearing initialized to Logic and allows a subsequent initialization attempt to start cleanly.
Logic may initialize on a worker while the idle timer and Cocoa editor run on the main thread. Share the AU SDK entry mutex with those paths so they cannot access plugin main-thread state concurrently. Idle skips a busy tick without consuming pending requests or blocking the UI thread. Start idle after port setup and keep the shared mutex alive through view teardown. Editor callbacks run under their caller's entry guard.
The UI connection's destroy callback already calls gui.destroy and clears the editor state. Remove the second gui.destroy call from Cleanup.
defiantnerd
reviewed
Sep 9, 2026
defiantnerd
reviewed
Sep 9, 2026
Collaborator
|
Thanks for the contribution - please run clang-format on your patches, so it can be merged. |
Author
|
Done! |
Collaborator
|
there are conflicts :( |
Collaborator
|
ahh and we don't have write access to resolve them to your branch. Let us know if you can or if we need to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses 4 issues I discovered while working on a plugin that serves as an offline audio generator.
If you would like me to split this into several PRs, please let me know.
These commits were made with the help of GPT-6 Astra and manually vetted and adjusted.
3780585First of all, my plugin was not outputting any audio in Logic despite producing samples.
As I mentioned, my plugin generates audio offline and can play it back on user demand, even when there is no incoming audio. The fix was to clear the "silent" flag from the output when it's set for the input.
121fe78My plugin was erroring during the CLAP activate callback and returned
false, but clap-wrapper reported it as fine to Logic. This commit properly respects the return value ofactivateandstart_processing.0aedc9cLogic activates my plugin on a worker thread, while clap-wrapper can call on_main_thread or access the editor on the main thread. These calls could overlap and access the same plugin state at the same time.
AlwaysMainThread()only changes the result returned by the thread check, it doesn't prevent this overlap. This commit adds a shared lock so these calls happen one at a time. If the plugin is busy, the idle callback is deferred to the next tick.a1ac38bDuring cleanup, clap-wrapper called gui.destroy twice: once through the editor’s cleanup callback and then again directly.