Skip to content

P0 native LIVE mixer: in-place safe capture PCM, MAIN/MONITOR single-pass + 10k RT regression - #255

Merged
masarray merged 4 commits into
mainfrom
fix/p0-live-pcm-alias-safe-production-mixer-20261031
Oct 31, 2026
Merged

masarray merged 4 commits into
mainfrom
fix/p0-live-pcm-alias-safe-production-mixer-20261031

Conversation

@masarray

Copy link
Copy Markdown
Owner

P0: Fix production (NOT prototype) realtime input/output alias safety

Evidence / motivation

User still hears 0-FX crackle despite powerful PC. Hardware evidence: 48k/480 WASAPI VB-Cable capture → MAONO render, 113 JUCE WASAPI capture discontinuity flags / 8,126 callbacks but 0 host DSP deadline overruns. That evidence is a capture continuity problem, NOT proof this alias bug caused the audible crackle. PR #251 separately owns capture zero-head de-click; this PR does not modify that code.

Independent code audit found 2 layers of pre-clearing native output PCM BEFORE real physical inputs were consumed:

  • LiveDryRoutingLab::process cleared all physical outputs before invoking the current 10CH native mixer;
  • PreparedMixerBlock::process cleared MAIN + MONITOR before reading input PCM in channel render order.
    A host/backend may provide aliased input/output backing (Steinberg VST3 buffer contract explicitly allows in-place processing), so a pre-clear can erase input in some supported buffer configurations. This is a production path safety hazard.

Source changes (one meaningful milestone, 3 files)

  • engine/core/PreparedMixerBlock.h: constructor preallocates one 2-channel MONITOR accumulator (2 * maxFrames float), keeps all source→sends→FX→master DSP in the existing single render pass, writes MAIN and independent MONITOR to physical output after all native source lanes are consumed. On invalid buffer/capacity still silence outputs. No callback heap/lock/worker, no additional plugin instance or graph. Buffer cost max 64 KiB at 8192 frames (2×8192×4 bytes).
  • src/LiveDryRoutingLab.h: preserve native device epoch/ACK/MUTE, delay clearing unselected physical output channels until after the prepared process, silence every rejected/unsafe route immediately, protect exact selected MAIN/MONITOR pointer aliases. Existing chunked 10CH, AUX, CH1 vendor FX, Show, secondary output and 256-frame de-click retained.
  • tests/prepared_mixer_block_test.cpp: exact 32-sample A/B PCM with four independent mono physical inputs that share backing memory with MAIN L/R and MONITOR L/R. Assert all four outputs sample-by-sample equal to non-aliased baseline. 10,000 PCM block soak with operator new allocation counter unchanged in MSVC Release. Real C++ test, not browser simulation.

Safety and scope

  • Does not turn on dynamic live CH11, master FX, new device or GUI engine; no WASAPI endpoint/clock change. Ownership remains one JUCE producer.
  • Does not claim to solve all crackle, render underruns, memory leak or cross-device clock drift.
  • CI required: exact-head Windows native CTest including 10CH PCM, and Chromium smoke; physical 0-FX A/B MAONO/ASIO/WASAPI FAT still required.

Refs: Steinberg VST3 API in-place buffer contract, #15, #251, #170, #192.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T16:08:35.303037Z 6f3e166 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@masarray
masarray merged commit 8ae4b82 into main Oct 31, 2026
1 check passed
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