instrument: narrow the live-param publish lock to its own mutex, off the reload's decode
Knob-drag publishes no longer block behind a full reload's WAV decode — a dedicated livePublishMutex_ replaces reloadMutex_ for the seqlock's single-writer contract. Also fixes an editor comment overclaim and two doc restatements.
This commit is contained in:
@@ -153,17 +153,14 @@ void ReaSamplerProcessor::setInstrumentParams(const InstrumentParams& params) {
|
||||
}
|
||||
|
||||
void ReaSamplerProcessor::publishLiveParams() {
|
||||
// reloadMutex_ enforces the block's SINGLE-WRITER contract (live_params.h), not the
|
||||
// reload's slot bookkeeping: reloadInstrument publishes the block too, and two concurrent
|
||||
// seqlock writers can leave the generation even mid-write, which a reader would accept as
|
||||
// a coherent — but torn — block. The audio thread never takes this mutex, so the cost is
|
||||
// an off-thread wait behind a reload. Lock order matches reloadInstrument's
|
||||
// (reloadMutex_ then paramsMutex_, taken by instrumentParams below).
|
||||
std::lock_guard<std::mutex> lock(reloadMutex_);
|
||||
const int rate = builtSampleRate_.load(std::memory_order_relaxed);
|
||||
if (rate <= 0) return;
|
||||
liveParams_.publish(
|
||||
instrument::engine::foldLive(resolvePlay(instrumentParams().play, rate)));
|
||||
const instrument::engine::LiveValues block =
|
||||
instrument::engine::foldLive(resolvePlay(instrumentParams().play, rate));
|
||||
// livePublishMutex_ enforces the seqlock's single-writer contract (live_params.h) against
|
||||
// reloadInstrument's publish — held for the publish call only, not the fold above.
|
||||
std::lock_guard<std::mutex> lock(livePublishMutex_);
|
||||
liveParams_.publish(block);
|
||||
}
|
||||
|
||||
SampleRefs ReaSamplerProcessor::sampleRefs() {
|
||||
|
||||
Reference in New Issue
Block a user