Skip to content

Standalone: keep activate/deactivate balanced when audio can't start - #506

Merged
defiantnerd merged 2 commits into
free-audio:nextfrom
defiantnerd:issue390
Aug 8, 2026
Merged

Standalone: keep activate/deactivate balanced when audio can't start#506
defiantnerd merged 2 commits into
free-audio:nextfrom
defiantnerd:issue390

Conversation

@defiantnerd

Copy link
Copy Markdown
Collaborator

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 #390

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
@defiantnerd
defiantnerd merged commit 690f9aa into free-audio:next Aug 8, 2026
28 checks passed
@defiantnerd
defiantnerd deleted the issue390 branch August 8, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant