From f4d49b19cfca026b42a96eaec06e0f90b43f1aa6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:05:33 +0700 Subject: [PATCH 1/8] feat(io1): reuse bounded SPSC ASRC with capture and primary epoch leases --- engine/device/SecondaryCaptureClockStream.h | 194 ++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 engine/device/SecondaryCaptureClockStream.h diff --git a/engine/device/SecondaryCaptureClockStream.h b/engine/device/SecondaryCaptureClockStream.h new file mode 100644 index 000000000..c8061ed5b --- /dev/null +++ b/engine/device/SecondaryCaptureClockStream.h @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "AdaptiveClockBridge.h" +#include "ClockBridgeSizing.h" +#include +#include +#include +#include +#include + +namespace armix::device +{ +// IO-1: one independently clocked CAPTURE producer -> one PRIMARY render +// consumer. Reuses the production bounded AdaptiveClockBridge SPSC/ASRC; +// NO mixer, VST3, output device, callback owner or audio heap allocation. +// prepare/activate/stop: CONTROL. push: ONLY the device-B callback. +// pull: ONLY the primary device-A callback, after explicit source admission. +// No session/physical DeviceKey -> ChannelId binding is claimed until IO-2. +class SecondaryCaptureClockStream final +{ +public: + static constexpr int capacityFrames=32768; + static constexpr int maxCallbackFrames=8192; + struct Format + { + double captureHz=0.,primaryHz=0.; + int capturePeriod=0,primaryPeriod=0,channels=0; + std::uint64_t captureGeneration=0,primaryEpoch=0; + }; + struct Status + { + bool ready=false,faulted=false; + std::uint64_t captureBlocks=0,primaryBlocks=0,invalidBlocks=0,staleReads=0; + AdaptiveClockBridge::Status asrc{}; + }; + + bool prepare(const Format& format,double desiredTargetMs=24.) noexcept + { + if(ready_.load(std::memory_order_acquire)|| + producers_.load(std::memory_order_acquire)!=0|| + consumers_.load(std::memory_order_acquire)!=0) + return false; + // CONTROL owns the entire format and bridge reprepare interval. + ready_.store(false,std::memory_order_release); + fault_.store(false,std::memory_order_release); + format_={};targetMs_=0.; + if(format.captureGeneration==0||format.primaryEpoch==0|| + format.channels<1||format.channels>16|| + format.capturePeriod<1||format.capturePeriod>maxCallbackFrames|| + format.primaryPeriod<1||format.primaryPeriod>maxCallbackFrames) + return false; + const auto sizing=ClockBridgeSizing::choose( + format.captureHz,format.primaryHz,format.capturePeriod, + format.primaryPeriod,AdaptiveClockBridge::taps, + capacityFrames,desiredTargetMs); + if(!sizing.valid||!bridge_.prepare(format.captureHz,format.primaryHz, + format.channels,capacityFrames,sizing.targetMs)) + return false; + format_=format;targetMs_=sizing.targetMs; + captureBlocks_.store(0,std::memory_order_relaxed); + primaryBlocks_.store(0,std::memory_order_relaxed); + invalidBlocks_.store(0,std::memory_order_relaxed); + staleReads_.store(0,std::memory_order_relaxed); + prepared_=true; + return true; + } + + bool activate() noexcept + { + if(!prepared_||fault_.load(std::memory_order_acquire)) + return false; + ready_.store(true,std::memory_order_release); + return true; + } + + // Fail an independent capture without disturbing PRIMARY playback. + void fault() noexcept + { + fault_.store(true,std::memory_order_release); + ready_.store(false,std::memory_order_release); + } + + // Device callbacks must be DETACHED before CONTROL calls stop(). + // A concurrently finishing primary pull is held by a short RT lease. + // Never call this or yield on either audio callback. + void stop() noexcept + { + ready_.store(false,std::memory_order_release); + while(producers_.load(std::memory_order_acquire)!=0|| + consumers_.load(std::memory_order_acquire)!=0) + std::this_thread::yield(); + prepared_=false; + fault_.store(false,std::memory_order_release); + bridge_.resetStopped(); // no live producer or consumer + format_={};targetMs_=0.; + } + + bool push(const float* const* capture,int channels,int frames) noexcept + { + producers_.fetch_add(1,std::memory_order_acq_rel); + const bool enabled=ready_.load(std::memory_order_acquire)&& + !fault_.load(std::memory_order_acquire); + if(!enabled){producers_.fetch_sub(1,std::memory_order_release);return false;} + if(!capture||channels!=format_.channels||frames<1|| + frames>maxCallbackFrames) + { + invalidBlocks_.fetch_add(1,std::memory_order_relaxed); + fault(); + producers_.fetch_sub(1,std::memory_order_release); + return false; + } + for(int c=0;c0&&frames>0&& + frames<=maxCallbackFrames; + if(!valid) + { + consumers_.fetch_sub(1,std::memory_order_release); + return false; + } + for(int c=0;c ready_{false},fault_{false}; + std::atomic producers_{0},consumers_{0}; + std::atomic captureBlocks_{0},primaryBlocks_{0}, + invalidBlocks_{0},staleReads_{0}; +}; +} // namespace armix::device From f116f78b4467c70104888e752d6387aaf4cc17d3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:07:32 +0700 Subject: [PATCH 2/8] feat(io1): real JUCE ASIO capture-only producer using existing clock bridge --- engine/device/LiveSecondaryCaptureDevice.h | 227 +++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 engine/device/LiveSecondaryCaptureDevice.h diff --git a/engine/device/LiveSecondaryCaptureDevice.h b/engine/device/LiveSecondaryCaptureDevice.h new file mode 100644 index 000000000..2e59fd701 --- /dev/null +++ b/engine/device/LiveSecondaryCaptureDevice.h @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "SecondaryCaptureClockStream.h" +#include "AsioPriorityDeviceManager.h" +#include "AsioRegistryIdentityProbe.h" +#include +#include +#include +#include +#include +#include + +namespace armix::device +{ +// IO-1 production-capable, explicit SECONDARY ASIO input-only device. +// The JUCE callback is a producer ONLY; it never invokes a mixer, VST3, +// WebView, file I/O or user-selected output. The primary ASIO render +// callback is the ONLY consumer, through pullForPrimary() after IO-2 source +// admission. A driver that requires an output channel is REJECTED, never +// silently turned into a speaker. No second AudioDeviceManager initialise. +class LiveSecondaryCaptureDevice final +{ + struct Capture final : juce::AudioIODeviceCallback + { + LiveSecondaryCaptureDevice& owner; + explicit Capture(LiveSecondaryCaptureDevice& o):owner(o){} + void audioDeviceAboutToStart(juce::AudioIODevice* d) override + { + // JUCE lifecycle, not the realtime sample callback. + if(!d||d->getName()!=owner.name_|| + d->getActiveInputChannels()!=owner.inputMask_|| + !d->getActiveOutputChannels().isZero()|| + std::abs(d->getCurrentSampleRate()-owner.captureRate_)>0.001|| + d->getCurrentBufferSizeSamples()!=owner.capturePeriod_) + owner.stream_.fault(); + } + void audioDeviceStopped() override + { + if(owner.opened_.load(std::memory_order_acquire)) + owner.stream_.fault(); + } + void audioDeviceError(const juce::String&) override {owner.stream_.fault();} + void audioDeviceIOCallbackWithContext( + const float* const* inputs,int inputsCount, + float* const* outputs,int outputsCount,int frames, + const juce::AudioIODeviceCallbackContext&) override + { + // Defensive silence if a broken driver produces output pointers. + for(int c=0;c0) + juce::FloatVectorOperations::clear(outputs[c],frames); + if(outputsCount!=0) + { + owner.stream_.fault(); + return; + } + // This is the ONLY capture writer; no plugin, render, allocation, + // lock, type scan, COM, registry, UI or disk work on this thread. + owner.stream_.push(inputs,inputsCount,frames); + } + }; +public: + struct Readback + { + juce::String driverName; // CONTROL-only, not an endpoint hardware GUID + juce::BigInteger activeInputPins; // physical indices, not callback order + double captureRate=0.,primaryRate=0.,bridgeTargetMs=0.; + int capturePeriod=0,primaryPeriod=0,callbackInputs=0; + std::uint64_t captureGeneration=0,primaryEpoch=0; + std::uint64_t driverClassFingerprint=0; // diagnostic, not authorization + bool ready=false,faulted=false; + SecondaryCaptureClockStream::Status clock{}; + }; + + LiveSecondaryCaptureDevice():capture_(*this){} + ~LiveSecondaryCaptureDevice(){close();} + LiveSecondaryCaptureDevice(const LiveSecondaryCaptureDevice&)=delete; + LiveSecondaryCaptureDevice& operator=(const LiveSecondaryCaptureDevice&)=delete; + + // Called ONLY after primary driver is stable, on serialized CONTROL. + // No requested software fallback, no 0-output -> duplex retry, no + // automatic speaker ARM. generation and primaryEpoch are native leases. + juce::String open(const juce::String& secondaryName, + const juce::String& primaryAsioName, + const juce::BigInteger& selectedInputPins, + double requestedCaptureHz,int requestedCapturePeriod, + double primaryHz,int primaryPeriod, + std::uint64_t captureGeneration, + std::uint64_t primaryEpoch) + { + close(); +#if !defined(_WIN32) || !JUCE_ASIO + (void)secondaryName;(void)primaryAsioName;(void)selectedInputPins; + (void)requestedCaptureHz;(void)requestedCapturePeriod; + (void)primaryHz;(void)primaryPeriod; + (void)captureGeneration;(void)primaryEpoch; + return "Independent ASIO capture is Windows JUCE ASIO only"; +#else + if(primaryAsioName.isEmpty()||secondaryName.isEmpty()|| + secondaryName==primaryAsioName||selectedInputPins.isZero()|| + selectedInputPins.countNumberOfSetBits()>16|| + selectedInputPins.getHighestBit()>=64|| + captureGeneration==0||primaryEpoch==0|| + !std::isfinite(requestedCaptureHz)|| + requestedCaptureHz<8000.||requestedCaptureHz>192000.|| + requestedCapturePeriod<32|| + requestedCapturePeriod>SecondaryCaptureClockStream::maxCallbackFrames) + return "Invalid explicit secondary ASIO capture selection"; + const std::wstring p(primaryAsioName.toWideCharPointer()); + const std::wstring b(secondaryName.toWideCharPointer()); + const auto primary=AsioRegistryIdentityProbe::resolve(p).registration; + const auto secondary=AsioRegistryIdentityProbe::resolve(b).registration; + if(!primary.ok()||!secondary.ok()|| + primary.identity.sameDriverClass(secondary.identity)) + return "Secondary ASIO must be an independently attested driver class"; + + enumerator_.createAudioDeviceTypes(factories_); + juce::AudioIODeviceType* asio=nullptr; + for(auto* type:factories_) + if(type->getTypeName()=="ASIO"){asio=type;break;} + if(!asio){close();return "JUCE ASIO backend is unavailable";} + asio->scanForDevices(); // CONTROL; never enumerate while callbacks run + if(!asio->getDeviceNames(true).contains(secondaryName)) + {close();return "Selected secondary ASIO input driver is missing";} + + // JUCE signature is createDevice(OUTPUT name, INPUT name). + device_.reset(asio->createDevice({},secondaryName)); + if(!device_){close();return "ASIO rejected capture-only construction";} + const juce::BigInteger noOutputs; + auto error=device_->open(selectedInputPins,noOutputs, + requestedCaptureHz,requestedCapturePeriod); + if(error.isNotEmpty()){close();return error;} + if(!device_->isOpen()||device_->getName()!=secondaryName|| + device_->getActiveInputChannels()!=selectedInputPins|| + !device_->getActiveOutputChannels().isZero()) + {close();return "ASIO changed input pins, output isolation, or device identity";} + const auto actualHz=device_->getCurrentSampleRate(); + const auto actualPeriod=device_->getCurrentBufferSizeSamples(); + if(std::abs(actualHz-requestedCaptureHz)>0.001|| + actualPeriod!=requestedCapturePeriod) + {close();return "ASIO changed the explicitly requested capture rate/period";} + const auto pAfter=AsioRegistryIdentityProbe::resolve(p).registration; + const auto bAfter=AsioRegistryIdentityProbe::resolve(b).registration; + if(!pAfter.ok()||!bAfter.ok()|| + !primary.identity.sameDriverClass(pAfter.identity)|| + !secondary.identity.sameDriverClass(bAfter.identity)) + {close();return "ASIO registry driver class changed during capture open";} + if(!stream_.prepare({actualHz,primaryHz,actualPeriod,primaryPeriod, + selectedInputPins.countNumberOfSetBits(), + captureGeneration,primaryEpoch})) + {close();return "Existing bounded clock bridge cannot admit negotiated periods";} + name_=secondaryName; + inputMask_=selectedInputPins; + captureRate_=actualHz;capturePeriod_=actualPeriod; + primaryRate_=primaryHz;primaryPeriod_=primaryPeriod; + generation_=captureGeneration;primaryEpoch_=primaryEpoch; + classFingerprint_=AsioRegistryIdentityProbe::diagnosticFingerprint( + secondary.identity); + if(!stream_.activate()){close();return "Capture bridge activation refused";} + opened_.store(true,std::memory_order_release); + device_->start(&capture_); + if(stream_.faulted()||!device_->isPlaying()) + {close();return "ASIO capture callback refused or changed its format";} + return {}; +#endif + } + + // CONTROL stop, idempotent. Detached device producer and primary reader + // are quiescent before bridge/FIR memory is reset or device is destroyed. + void close() + { + opened_.store(false,std::memory_order_release); + stream_.fault(); + if(device_){device_->stop();device_->close();} + stream_.stop(); + device_.reset(); // must be destroyed before its ASIO factory + factories_.clear(); + name_.clear();inputMask_.clear(); + captureRate_=primaryRate_=0.; + capturePeriod_=primaryPeriod_=0; + generation_=primaryEpoch_=classFingerprint_=0; + } + + // RT primary render-clock READ ONLY. Return silence on stale primary + // device epoch, stale capture generation, stalled/faulted secondary, or + // non-admitted channel format. No DSP or secondary device access. + bool pullForPrimary(float* const* dest,int channels,int frames, + std::uint64_t captureGeneration, + std::uint64_t primaryEpoch) noexcept + { + return stream_.pull(dest,channels,frames,captureGeneration,primaryEpoch); + } + void invalidatePrimaryClock() noexcept {stream_.fault();} + bool ready() const noexcept{return opened_.load(std::memory_order_acquire)&& + stream_.ready();} + bool faulted() const noexcept{return stream_.faulted();} + Readback readback() const // CONTROL only: called after driver lifecycle + { + Readback b; + b.driverName=name_; + b.activeInputPins=inputMask_; + b.captureRate=captureRate_;b.primaryRate=primaryRate_; + b.capturePeriod=capturePeriod_;b.primaryPeriod=primaryPeriod_; + b.callbackInputs=inputMask_.countNumberOfSetBits(); + b.bridgeTargetMs=stream_.targetMs(); + b.captureGeneration=generation_; + b.primaryEpoch=primaryEpoch_; + b.driverClassFingerprint=classFingerprint_; + b.ready=ready();b.faulted=faulted(); + b.clock=stream_.status(); + return b; + } + +private: + AsioPriorityDeviceManager enumerator_; // never initialise a default device + juce::OwnedArray factories_; // outlive device_ + std::unique_ptr device_; + SecondaryCaptureClockStream stream_; + Capture capture_; + juce::String name_; + juce::BigInteger inputMask_; + double captureRate_=0.,primaryRate_=0.; + int capturePeriod_=0,primaryPeriod_=0; + std::uint64_t generation_=0,primaryEpoch_=0,classFingerprint_=0; + std::atomic opened_{false}; +}; +} // namespace armix::device From a63ac631be0d03201c4b4ca0839a22fb5d57ab54 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:08:46 +0700 Subject: [PATCH 3/8] test(io1): 9 independent clock pairs, stale generation, overflow, finite PCM and isolated secondary fault --- tests/secondary_capture_clock_stream_test.cpp | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/secondary_capture_clock_stream_test.cpp diff --git a/tests/secondary_capture_clock_stream_test.cpp b/tests/secondary_capture_clock_stream_test.cpp new file mode 100644 index 000000000..efaad23db --- /dev/null +++ b/tests/secondary_capture_clock_stream_test.cpp @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/device/SecondaryCaptureClockStream.h" +#include +#include +#include +#include +#include +#include + +using Stream=armix::device::SecondaryCaptureClockStream; +static void check(bool ok){if(!ok){std::fputs("IO1_CLOCK_CAPTURE_FAIL\n",stderr);std::abort();}} + +static void oneClockPair(double captureHz,double primaryHz) +{ + Stream s; + const Stream::Format f{captureHz,primaryHz,128,256,2,7,19}; + check(s.prepare(f)); + check(s.targetMs()>=24.); + check(s.activate()); + std::array left{},right{},destL{},destR{}; + const float* write[2]={left.data(),right.data()}; + float* read[2]={destL.data(),destR.data()}; + for(int i=0;i<256;++i) + { + left[i]=static_cast(0.21*std::sin(0.075*i)); + right[i]=static_cast(0.37*std::cos(0.045*i)); + } + for(int i=0;i<16;++i)check(s.push(write,2,256)); + check(!s.pull(read,2,256,7,18)); // old primary epoch: cannot consume + check(destL[0]==0.f&&destR[255]==0.f); + check(!s.pull(read,2,256,6,19)); // stale capture generation + check(destL[77]==0.f&&destR[8]==0.f); + bool nonzero=false; + for(int block=0;block<48;++block) + { + check(s.pull(read,2,256,7,19)); + for(int j=0;j<256;++j) + { + check(std::isfinite(destL[j])&&std::isfinite(destR[j])); + if(std::abs(destL[j])>0.003f&&std::abs(destR[j])>0.003f) + nonzero=true; + } + if(block%2==0)check(s.push(write,2,256)); + } + check(nonzero); + const auto stats=s.status(); + check(stats.captureBlocks>=40&&stats.primaryBlocks==48); + check(stats.staleReads==2&&stats.asrc.pushedFrames>0); + check(stats.asrc.renderedFrames>0); + s.fault(); + check(!s.ready()&&s.faulted()); + destL.fill(0.5f);destR.fill(0.5f); + check(!s.pull(read,2,256,7,19)); + check(destL[0]==0.f&&destR[255]==0.f); + s.stop(); + check(!s.ready()&&!s.faulted()); + check(s.prepare({48000.,48000.,128,256,1,8,20})); + check(s.activate()); + const float* mono[1]={left.data()}; + check(s.push(mono,1,128)); + s.stop(); +} + +static void invalidAndOverflow() +{ + Stream s; + check(!s.prepare({48000.,48000.,128,128,0,1,1})); + check(!s.prepare({48000.,48000.,128,128,2,0,1})); + check(!s.prepare({48000.,48000.,128,128,2,1,0})); + check(!s.prepare({48000.,48000.,32769,128,2,1,1})); + check(!s.prepare({48000.,48000.,128,32769,2,1,1})); + check(!s.prepare({48000.,48000.,8192,8192,2,1,1})); + check(s.prepare({48000.,48000.,128,128,2,2,3})); + check(s.activate()); + check(!s.prepare({48000.,48000.,128,128,2,4,3})); // live reset forbidden + std::array left{},right{}; + const float* write[2]={left.data(),right.data()}; + left[0]=std::numeric_limits::quiet_NaN(); + right[17]=std::numeric_limits::infinity(); + for(int b=0;b<4;++b)check(s.push(write,2,8192)); + check(!s.push(write,2,128)); // bounded ring drops newest + const auto before=s.status(); + check(before.asrc.overflowFrames>=128); + check(before.asrc.nonFiniteInputSamples>=8); + check(s.ready()); // healthy producer overflow does not kill primary + s.stop(); + check(s.prepare({48000.,48000.,128,128,2,3,4})); + check(s.activate()); + check(!s.push(write,1,128)); // wrong callback channel count fail closed + check(s.faulted()&&!s.ready()); + std::array l{},r{}; + float* out[2]={l.data(),r.data()}; + l.fill(1.f);r.fill(1.f); + check(!s.pull(out,2,128,3,4)); + check(l[44]==0.f&&r[127]==0.f); + s.stop(); +} +int main() +{ + for(double capture:{44100.,48000.,96000.}) + for(double primary:{44100.,48000.,96000.}) + oneClockPair(capture,primary); + invalidAndOverflow(); + std::puts("IO1_CLOCK_CAPTURE_PASS 9x rates, identity epochs, FIFO, fault isolation"); +} From 8abc4e822cf751623214a2ad5bd92a3f727d2406 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:09:58 +0700 Subject: [PATCH 4/8] test(io1): compile actual capture-only JUCE adapter with hardware-free negative lifecycle --- tests/asio_backend_registration_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/asio_backend_registration_test.cpp b/tests/asio_backend_registration_test.cpp index b861f8d41..efe0313cb 100644 --- a/tests/asio_backend_registration_test.cpp +++ b/tests/asio_backend_registration_test.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only #include "../engine/device/AsioPriorityDeviceManager.h" #include "../engine/device/AudioSetupRecoveryPolicy.h" +#include "../engine/device/LiveSecondaryCaptureDevice.h" #include int main() { @@ -34,6 +35,20 @@ int main() if (type->getTypeName() == "Windows Audio") foundWasapi = true; } if (!foundAsio || !foundWasapi) std::abort(); + // IO-1: the SAME production capture-only class is compiled and its + // negative lifecycle is checked without opening ANY ASIO driver in CI. + armix::device::LiveSecondaryCaptureDevice extra; + if (extra.ready() || extra.faulted()) std::abort(); + juce::BigInteger pin; pin.setBit(0); + if (extra.open({}, {}, pin, 48000., 128, 48000., 128, 1, 1).isEmpty()) + std::abort(); + if (extra.ready()) std::abort(); + extra.close(); + extra.close(); + const auto readback = extra.readback(); + if (readback.ready || readback.captureGeneration != 0 || + readback.primaryEpoch != 0 || readback.callbackInputs != 0) + std::abort(); #endif return 0; } From 7163f54e35d5f28bba01f238fe2e7444d1142d8c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:10:23 +0700 Subject: [PATCH 5/8] build(io1): register native capture ASRC CTest and compile production JUCE ASIO adapter --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b65591033..794dac17a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,7 +337,7 @@ juce_add_binary_data(ARMixAssets SOURCES ${ARMIX_IMERSIB_SCENE_PNG_SOURCES}) target_include_directories(ARMixConsole PRIVATE "${ARMIX_APPROVED_GUI_DIR}") -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h engine/builtin_fx/SonKuSpatialProcessor.h engine/builtin_fx/sonku/SonKuSpatialCore.h engine/builtin_fx/sonku/SonKuMeasuredHrir.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h engine/builtin_fx/SonKuSpatialProcessor.h engine/builtin_fx/sonku/SonKuSpatialCore.h engine/builtin_fx/sonku/SonKuMeasuredHrir.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/device/LiveSecondaryCaptureDevice.h engine/device/SecondaryCaptureClockStream.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) # Explicit UTF-8 source decoding: native channel icons are Unicode, and # MSVC's machine-specific ANSI source charset corrupts emoji literals. # Limit the flag to C++ (not Windows .rc/resource compilation). @@ -1410,11 +1410,20 @@ if(BUILD_TESTING) target_compile_features(ARMixIo0DualAsioPolicyTests PRIVATE cxx_std_20) add_test(NAME IO0DualVendorCaptureDriverIdentityAndPhysicalMasks COMMAND ARMixIo0DualAsioPolicyTests) + # IO-1: driver-independent production SPSC/ASRC capture lease regression. + # The actual JUCE input-only hardware class is compiled in the existing + # Windows ASIO backend test; unattended CI NEVER opens its physical driver. + add_executable(ARMixIo1CaptureClockTests + tests/secondary_capture_clock_stream_test.cpp + engine/device/SecondaryCaptureClockStream.h) + target_compile_features(ARMixIo1CaptureClockTests PRIVATE cxx_std_20) + add_test(NAME IO1SecondaryCaptureEpochAndNineClockDomains + COMMAND ARMixIo1CaptureClockTests) if(WIN32) juce_add_console_app(ARMixAsioBackendTests PRODUCT_NAME "ArSonMix ASIO Backend Registration Tests") target_sources(ARMixAsioBackendTests PRIVATE tests/asio_backend_registration_test.cpp engine/device/AsioPriorityDeviceManager.h) target_compile_definitions(ARMixAsioBackendTests PRIVATE JUCE_ASIO=1) - target_link_libraries(ARMixAsioBackendTests PRIVATE juce::juce_audio_devices juce::juce_recommended_config_flags) + target_link_libraries(ARMixAsioBackendTests PRIVATE juce::juce_audio_devices juce::juce_recommended_config_flags advapi32) target_compile_features(ARMixAsioBackendTests PRIVATE cxx_std_20) add_test(NAME AsioNativeBackendRegistered COMMAND ARMixAsioBackendTests) juce_add_console_app(ARMixDualJuceTests PRODUCT_NAME "ArSonMix Independent JUCE Device Tests") From fd703369f09ed578fe9daf48a1e613eadf8dcc74 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:11:00 +0700 Subject: [PATCH 6/8] fix(io1): keep control-time ASRC allocations throwable and bound primary output channel count --- engine/device/SecondaryCaptureClockStream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/device/SecondaryCaptureClockStream.h b/engine/device/SecondaryCaptureClockStream.h index c8061ed5b..cf3e143df 100644 --- a/engine/device/SecondaryCaptureClockStream.h +++ b/engine/device/SecondaryCaptureClockStream.h @@ -34,7 +34,7 @@ class SecondaryCaptureClockStream final AdaptiveClockBridge::Status asrc{}; }; - bool prepare(const Format& format,double desiredTargetMs=24.) noexcept + bool prepare(const Format& format,double desiredTargetMs=24.) { if(ready_.load(std::memory_order_acquire)|| producers_.load(std::memory_order_acquire)!=0|| @@ -128,7 +128,7 @@ class SecondaryCaptureClockStream final std::uint64_t captureGeneration,std::uint64_t primaryEpoch) noexcept { consumers_.fetch_add(1,std::memory_order_acq_rel); - const bool valid=output&&channels>0&&frames>0&& + const bool valid=output&&channels>0&&channels<=16&&frames>0&& frames<=maxCallbackFrames; if(!valid) { From ec8a4fe35c264de64304be39d21fe535628a9516 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:32:40 +0700 Subject: [PATCH 7/8] fix(io1): invalidate unactivated prepared clock lease before replacement preflight --- engine/device/SecondaryCaptureClockStream.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/device/SecondaryCaptureClockStream.h b/engine/device/SecondaryCaptureClockStream.h index cf3e143df..9d6573578 100644 --- a/engine/device/SecondaryCaptureClockStream.h +++ b/engine/device/SecondaryCaptureClockStream.h @@ -43,6 +43,10 @@ class SecondaryCaptureClockStream final // CONTROL owns the entire format and bridge reprepare interval. ready_.store(false,std::memory_order_release); fault_.store(false,std::memory_order_release); + // A previous successfully prepared (but not activated) stream must + // never survive an invalid replacement request. activate() may not + // re-arm a stale bridge after ANY prepare failure. + prepared_=false; format_={};targetMs_=0.; if(format.captureGeneration==0||format.primaryEpoch==0|| format.channels<1||format.channels>16|| From a0af6448c19d20d35830271c07803f41fe9ea85b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:32:58 +0700 Subject: [PATCH 8/8] test(io1): reject stale activation after invalid replacement prepare --- tests/secondary_capture_clock_stream_test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/secondary_capture_clock_stream_test.cpp b/tests/secondary_capture_clock_stream_test.cpp index efaad23db..81e90741e 100644 --- a/tests/secondary_capture_clock_stream_test.cpp +++ b/tests/secondary_capture_clock_stream_test.cpp @@ -70,6 +70,18 @@ static void invalidAndOverflow() check(!s.prepare({48000.,48000.,32769,128,2,1,1})); check(!s.prepare({48000.,48000.,128,32769,2,1,1})); check(!s.prepare({48000.,48000.,8192,8192,2,1,1})); + + // A rejected replacement of a valid, unactivated preflight must NOT + // leave its previous bridge armed. Before this regression, prepared_ + // remained true and activate() falsely accepted an empty format. + check(s.prepare({48000.,48000.,128,128,2,1,1})); + check(!s.prepare({48000.,48000.,128,128,0,1,1})); + check(!s.activate()); + check(!s.ready()); + check(s.format().channels==0); + check(!s.prepare({48000.,48000.,8192,8192,2,1,1})); + check(!s.activate()); + s.stop(); check(s.prepare({48000.,48000.,128,128,2,2,3})); check(s.activate()); check(!s.prepare({48000.,48000.,128,128,2,4,3})); // live reset forbidden