pS-usage: captures held by live ReaSampler 9000 instances are un-prunable — instances publish usage_<guid> ext-state records (ComponentState v11), prune unions live holds into referenced

This commit is contained in:
2026-07-28 12:56:36 -04:00
parent f988ded543
commit 5886ae1456
19 changed files with 1282 additions and 10 deletions
+24
View File
@@ -302,6 +302,19 @@ private:
// safety-critical swap dance (see the handoff proof below).
void publishBuiltLocked(std::unique_ptr<LoadedInstrument> built);
// pS-usage: publish this instance's held captures to its per-instance ext-state key
// ("usage_<instanceGuid>") so the extension's prune counts them as referenced — a
// capture a live instance holds can never be pruned. Called at the end of every
// reloadInstrument (the ONE choke point every play-set change funnels through:
// selection change, zone edits, assignment consume, bank refresh, setState load), so
// publishing is EAGER and needs no timer — a closed-editor instance's record is
// already in ext-state from its last change/load. OFF THE AUDIO THREAD only (bridge
// calls). Mints instanceGuid_ on first need; RE-mints when planUsagePublish detects
// this state was cloned onto another track (FX copy / track duplication). Idempotent
// on an unchanged play-set (skipWrite). `refs`/`ids` are reloadInstrument's own
// snapshot — the refs table and the id set the instance currently plays.
void publishUsage(const SampleRefs& refs, const std::vector<std::string>& ids);
ReaperBridge bridge_;
// --- The audio-thread handoff (S4 real-time discipline, FA1 drain slot) --
@@ -368,6 +381,17 @@ private:
std::mutex refsMutex_;
SampleRefs sampleRefs_;
// pS-usage publish identity + lifetime memory (see publishUsage). instanceGuid_ is
// the persisted per-instance identity (ComponentState v11; empty until first
// publish); lastPublishedUsageWire_ is what THIS lifetime last wrote — the
// planUsagePublish discriminator between "my own key" (clean replace) and "a
// copy-source's key" (union / re-mint), cleared on setState (a new blob is a new
// lifetime for the collision analysis). Guarded by usageMutex_ (publish runs under
// reloadMutex_ but getState/setState do not).
std::mutex usageMutex_;
std::string instanceGuid_;
std::string lastPublishedUsageWire_;
// The per-instance channel mode (S7). Off-thread only (UI + getState + reloadInstrument);
// guarded against a getState/editor race. Default Mono preserves pre-S7 behavior. NOT read
// on the audio thread — process renders against the host's negotiated output channel count.