Standalone: keep activate/deactivate balanced when audio can't start - #506
Merged
Conversation
activate() is only called from activatePlugin(), which runs after RtAudio opens a stream. But mainFinish() called plugin->deactivate() unconditionally. With no usable audio device the plugin got a deactivate() with no matching activate(), which clap-helpers flags. Activation state now lives in StandaloneHost. activatePlugin() returns whether it succeeded, and only marks the plugin active once activate() returns true. The new deactivatePlugin() is a no-op unless activation actually happened. It also pairs stop_processing() with start_processing(), which the old shutdown path skipped entirely. The audio startup path is now guarded against exceptions, including COM/winrt errors that don't derive from std::exception. A throwing backend leaves the app running without audio instead of half-started. A failed activation closes the stream rather than processing into an inactive plugin. The restart handlers on Windows and macOS derive `running` from the activation result, so a failed reactivation doesn't resume the audio callback. Also fixes a null dereference in the Windows loadSettings(). It reached RtAudio's static API-name helpers through sah->rtaDac, before any RtAudio instance exists. Fixes free-audio#390
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.
activate() is only called from activatePlugin(), which runs after RtAudio opens
a stream. But mainFinish() called plugin->deactivate() unconditionally. With no
usable audio device the plugin got a deactivate() with no matching activate(),
which clap-helpers flags.
Activation state now lives in StandaloneHost. activatePlugin() returns whether
it succeeded, and only marks the plugin active once activate() returns true.
The new deactivatePlugin() is a no-op unless activation actually happened. It
also pairs stop_processing() with start_processing(), which the old shutdown
path skipped entirely.
The audio startup path is now guarded against exceptions, including COM/winrt
errors that don't derive from std::exception. A throwing backend leaves the app
running without audio instead of half-started. A failed activation closes the
stream rather than processing into an inactive plugin. The restart handlers on
Windows and macOS derive
runningfrom the activation result, so a failedreactivation doesn't resume the audio callback.
Also fixes a null dereference in the Windows loadSettings(). It reached
RtAudio's static API-name helpers through sah->rtaDac, before any RtAudio
instance exists.
Fixes #390