Skip to content

Protect processor teardown and oversampling changes from in-flight rendering - #1212

Open
jiri-god wants to merge 2 commits into
kushview:mainfrom
jiri-god:fix/render-lifecycle
Open

jiri-god wants to merge 2 commits into
kushview:mainfrom
jiri-god:fix/render-lifecycle

Conversation

@jiri-god

@jiri-god jiri-god commented Oct 29, 2026 •

Copy link
Copy Markdown

Disabling a node can currently call releaseResources() and reset its oversampler/RMS meters while an audio block is still using them. Off-message-thread enable requests also toggle the current state rather than applying the requested state; a quick off/on pair can therefore leave the node disabled. Off-thread oversampling can reconfigure the chain before the queued disable has executed.

This adds an atomic render-admission lease around the complete node render operation, including oversampling, gain and meters. Unprepare closes admission and waits for existing users on the control/device lifecycle thread before releasing resources. A closed gate never makes the audio callback wait. Admission reopens only after prepare and meter allocation complete.

Enable and oversampling requests are marshalled to the message thread with their requested values. Internal temporary disable/re-enable during oversampling does not overwrite a newer externally requested enabled state. Root device stop/start still relies on the existing engine lifecycle synchronization; this is not a claim that arbitrary plugin state edits or graph edits are lock-free.

Validation on Apple Silicon macOS, RelWithDebInfo:

  • A blocked test processor demonstrates releaseResources() being called inside processBlock() on unmodified d0226686; the subsequent concurrent stress also triggers SIGTRAP there.
  • New tests exercise a whole in-flight block, 300 disable/enable cycles plus oversampling changes during rendering, queued off/on requests, and newer requests superseding queued reconfiguration. Tests have bounded startup waits and a CTest timeout.
  • With this patch: all 59 CTest suites pass (3.85 s).

Independent of the sample-unit correction in #1211. Linux/Windows validation is pending CI.

Combined validation: the four independent branches (#1211–#1214) merge without conflicts and all 62 CTest suites pass together on Apple Silicon macOS (4.06 s). Upstream Build/REUSE runs currently report action_required pending maintainer approval for this fork; no cross-platform CI success is claimed.
The concurrent lifecycle suite also passed 20 consecutive runs (4.63 s total).

@mfisher31

Copy link
Copy Markdown
Member

@claude - can you review this?

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.

2 participants