From 34157c09f359fd9d9cb4cc782058a1109f0bfb86 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:27:32 +0700 Subject: [PATCH 01/10] feat(io0): add fail-closed dual-ASIO capture readback and driver class policy --- engine/device/DualAsioCaptureProbePolicy.h | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 engine/device/DualAsioCaptureProbePolicy.h diff --git a/engine/device/DualAsioCaptureProbePolicy.h b/engine/device/DualAsioCaptureProbePolicy.h new file mode 100644 index 000000000..e3e7c4d76 --- /dev/null +++ b/engine/device/DualAsioCaptureProbePolicy.h @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "AsioRegistrationPolicy.h" +#include +#include +#include + +namespace armix::device +{ +// IO-0, CONTROL-only: conservative compatibility probe policy, NOT a +// production source binding or a claim that a registered class can open. +// Distinct ASIO driver classes are necessary but NOT sufficient evidence of +// two independently usable physical interfaces. +class DualAsioCaptureProbePolicy final +{ +public: + using Identity = AsioRegistrationPolicy::Identity; + enum class Verdict : std::uint8_t + { + ok, missingSelection, unverifiedPrimaryDriver, unverifiedCaptureDriver, + sameDriverClass, wrongPrimaryEndpoint, wrongCaptureEndpoint, + invalidFormat, primaryOutputMissing, captureInputMissing, + captureOutputUnexpected, primaryMaskChanged, captureMaskChanged + }; + + struct Request + { + std::wstring_view primaryName, captureName; + Identity primary, capture; + std::uint64_t primaryInputMask = 0x3; + std::uint64_t primaryOutputMask = 0x3; + std::uint64_t captureInputMask = 0x1; + }; + struct Readback + { + std::wstring_view primaryName, captureName; + double primaryRate = 0., captureRate = 0.; + int primaryPeriod = 0, capturePeriod = 0; + std::uint64_t primaryInputMask = 0, primaryOutputMask = 0; + std::uint64_t captureInputMask = 0, captureOutputMask = 0; + }; + + static Verdict preflight(const Request& r) noexcept + { + if (r.primaryName.empty() || r.captureName.empty()) + return Verdict::missingSelection; + if (!r.primary.valid()) return Verdict::unverifiedPrimaryDriver; + if (!r.capture.valid()) return Verdict::unverifiedCaptureDriver; + if (r.primary.sameDriverClass(r.capture) || + r.primaryName == r.captureName) + return Verdict::sameDriverClass; + if (r.primaryOutputMask == 0 || r.captureInputMask == 0) + return Verdict::invalidFormat; + return Verdict::ok; + } + + static Verdict verify(const Request& r, const Readback& a) noexcept + { + const auto ready=preflight(r); + if (ready!=Verdict::ok) return ready; + if (a.primaryName!=r.primaryName) return Verdict::wrongPrimaryEndpoint; + if (a.captureName!=r.captureName) return Verdict::wrongCaptureEndpoint; + if (!std::isfinite(a.primaryRate)||!std::isfinite(a.captureRate)|| + a.primaryRate<8000.||a.captureRate<8000.|| + a.primaryRate>384000.||a.captureRate>384000.|| + a.primaryPeriod<=0||a.capturePeriod<=0) + return Verdict::invalidFormat; + if ((a.primaryOutputMask & 0x3u)!=0x3u) + return Verdict::primaryOutputMissing; + if (a.captureInputMask==0) return Verdict::captureInputMissing; + if (a.captureOutputMask!=0) return Verdict::captureOutputUnexpected; + if (a.primaryInputMask!=r.primaryInputMask|| + a.primaryOutputMask!=r.primaryOutputMask) + return Verdict::primaryMaskChanged; + if (a.captureInputMask!=r.captureInputMask) + return Verdict::captureMaskChanged; + return Verdict::ok; + } + + static const char* reason(Verdict v) noexcept + { + switch(v) + { + case Verdict::ok: return "IO0_EXACT_ASIO_READBACK"; + case Verdict::missingSelection: return "IO0_MISSING_EXPLICIT_DRIVER"; + case Verdict::unverifiedPrimaryDriver: return "IO0_PRIMARY_CLASS_NOT_ATTESTED"; + case Verdict::unverifiedCaptureDriver: return "IO0_CAPTURE_CLASS_NOT_ATTESTED"; + case Verdict::sameDriverClass: return "IO0_REQUIRES_DISTINCT_ASIO_CLASSES"; + case Verdict::wrongPrimaryEndpoint: return "IO0_PRIMARY_NAME_SUBSTITUTED"; + case Verdict::wrongCaptureEndpoint: return "IO0_CAPTURE_NAME_SUBSTITUTED"; + case Verdict::invalidFormat: return "IO0_NEGOTIATED_FORMAT_INVALID"; + case Verdict::primaryOutputMissing: return "IO0_PRIMARY_OUTPUT_STEREO_MISSING"; + case Verdict::captureInputMissing: return "IO0_CAPTURE_INPUT_MISSING"; + case Verdict::captureOutputUnexpected: return "IO0_SECONDARY_CAPTURE_MUST_HAVE_ZERO_OUTPUTS"; + case Verdict::primaryMaskChanged: return "IO0_PRIMARY_PIN_MASK_CHANGED"; + case Verdict::captureMaskChanged: return "IO0_CAPTURE_PIN_MASK_CHANGED"; + } + return "IO0_UNKNOWN_FAILURE"; + } +}; +} // namespace armix::device From 20cfdb2aca2dc3c3455798a14ef22de43790503f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:27:58 +0700 Subject: [PATCH 02/10] test(io0): reject wrong driver, capture output, sparse mask mismatches and unsafe clock periods --- tests/dual_asio_capture_probe_policy_test.cpp | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/dual_asio_capture_probe_policy_test.cpp diff --git a/tests/dual_asio_capture_probe_policy_test.cpp b/tests/dual_asio_capture_probe_policy_test.cpp new file mode 100644 index 000000000..5d05e1ade --- /dev/null +++ b/tests/dual_asio_capture_probe_policy_test.cpp @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/device/DualAsioCaptureProbePolicy.h" +#include "../engine/device/ClockBridgeSizing.h" +#include +#include +#include + +using Policy=armix::device::DualAsioCaptureProbePolicy; +using V=Policy::Verdict; + +int main() +{ + const Policy::Identity a{L"ASIO Vendor A",L"{11111111-1111-1111-1111-111111111111}"}; + const Policy::Identity b{L"ASIO Vendor B",L"{22222222-2222-2222-2222-222222222222}"}; + Policy::Request wanted{L"Vendor A ASIO",L"Vendor B ASIO",a,b,3,3,1}; + Policy::Readback actual{L"Vendor A ASIO",L"Vendor B ASIO", + 48000.,44100.,256,128,3,3,1,0}; + assert(Policy::preflight(wanted)==V::ok); + assert(Policy::verify(wanted,actual)==V::ok); + assert(Policy::preflight({L"Vendor A ASIO",L"Vendor A ASIO",a,a})== + V::sameDriverClass); + assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,a})== + V::sameDriverClass); + assert(Policy::preflight({L"",L"Vendor B ASIO",a,b})== + V::missingSelection); + assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",{},b})== + V::unverifiedPrimaryDriver); + assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,{}})== + V::unverifiedCaptureDriver); + auto changed=actual; + changed.captureName=L"USB Audio with same channel names"; + assert(Policy::verify(wanted,changed)==V::wrongCaptureEndpoint); + changed=actual; + changed.primaryName=L"Unexpected output"; + assert(Policy::verify(wanted,changed)==V::wrongPrimaryEndpoint); + changed=actual; + changed.primaryOutputMask=1; + assert(Policy::verify(wanted,changed)==V::primaryOutputMissing); + changed=actual; + changed.primaryInputMask=1; + assert(Policy::verify(wanted,changed)==V::primaryMaskChanged); + changed=actual; + changed.captureInputMask=0; + assert(Policy::verify(wanted,changed)==V::captureInputMissing); + changed=actual; + changed.captureOutputMask=3; + assert(Policy::verify(wanted,changed)==V::captureOutputUnexpected); + changed=actual; + changed.captureInputMask=2; + assert(Policy::verify(wanted,changed)==V::captureMaskChanged); + changed=actual; + changed.captureRate=0; + assert(Policy::verify(wanted,changed)==V::invalidFormat); + changed=actual; + changed.primaryPeriod=0; + assert(Policy::verify(wanted,changed)==V::invalidFormat); + + // Reuse production ASRC sizing. Different clocks always need a bounded + // prepared source bridge in IO-1; IO-0 does not insert one into primary. + for (const double source : {44100.,48000.,96000.}) + for (const double primary : {44100.,48000.,96000.}) + { + const auto sizing=armix::device::ClockBridgeSizing::choose( + source,primary,128,256,48,32768,24.); + assert(sizing.valid); + assert(sizing.targetMs>=24.); + assert(sizing.minFrames>0); + } + const auto impossible=armix::device::ClockBridgeSizing::choose( + 48000.,48000.,32768,32768,48,32768,24.); + assert(!impossible.valid); + std::puts("IO0_POLICY_PASS: identity, zero-output capture, exact masks, 9 clock profiles"); + return 0; +} From 5f63177d0d7d4660f00c2ce435180d563af8284d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:29:59 +0700 Subject: [PATCH 03/10] feat(io0): real opt-in dual ASIO primary+capture-only JUCE driver probe without DSP graph --- tools/dual_asio_capture_probe.cpp | 238 ++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 tools/dual_asio_capture_probe.cpp diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp new file mode 100644 index 000000000..dc31c81e9 --- /dev/null +++ b/tools/dual_asio_capture_probe.cpp @@ -0,0 +1,238 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// IO-0 physical dual-vendor ASIO compatibility probe, NOT the ArSonMix mixer. +// This executable never renders DSP/VST3, never changes the product session, +// and never routes secondary capture to a speaker. Its explicit primary +// callback writes only zeroes. Run only with owner-approved disconnected or +// muted speakers and a deliberate test input signal on ASIO B Input 1. +// +// Normal CTest --self-test performs NO hardware enumeration or driver opens. +// Explicit manual: ARMixDualAsioCaptureProbe --probe "Vendor A ASIO" "Vendor B ASIO" 48000 256 5000 +#include "../engine/device/DualAsioCaptureProbePolicy.h" +#include "../engine/device/AsioRegistryIdentityProbe.h" +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +using Policy=armix::device::DualAsioCaptureProbePolicy; +struct CaptureCounters final : juce::AudioIODeviceCallback +{ + bool primary=false; + int expectedInputs=0,expectedOutputs=0; + std::atomic calls{0},frames{0},nonzero{0},nonfinite{0}; + std::atomic violated{false}; + explicit CaptureCounters(bool isPrimary) : primary(isPrimary) {} + void audioDeviceAboutToStart(juce::AudioIODevice*) override {} + void audioDeviceStopped() override {} + void audioDeviceError(const juce::String&) override + { + violated.store(true,std::memory_order_release); + } + void audioDeviceIOCallbackWithContext( + const float* const* input,int inputs,float* const* output,int outputs, + int samples,const juce::AudioIODeviceCallbackContext&) override + { + // Never drive hardware, even on the explicitly opened primary. + for(int c=0;c(samples),std::memory_order_relaxed); + if(primary) return; // zero-output capture producer, NO graph or DSP + std::uint64_t live=0,bad=0; + for(int c=0;c0.0001f) ++live; + } + } + if(live)nonzero.fetch_add(live,std::memory_order_relaxed); + if(bad)nonfinite.fetch_add(bad,std::memory_order_relaxed); + } +}; + +struct Endpoint final +{ + juce::AudioDeviceManager discoveryOnly; // never initialise / open defaults + juce::OwnedArray factories; + std::unique_ptr device; + CaptureCounters counters; + explicit Endpoint(bool primary) : counters(primary) {} + ~Endpoint() + { + if(device){device->stop();device->close();device.reset();} + // Factories outlive their created devices. + } + juce::String openExact(const juce::String& selected, bool primary, + double rate,int frames) + { + discoveryOnly.createAudioDeviceTypes(factories); + juce::AudioIODeviceType* asio=nullptr; + for(auto* t:factories) if(t->getTypeName()=="ASIO"){asio=t;break;} + if(!asio)return "Pinned JUCE build has no ASIO device type"; + asio->scanForDevices(); // CONTROL, before opening; never on callback + if(!asio->getDeviceNames(primary).contains(selected) || + (primary&&!asio->getDeviceNames(false).contains(selected))) + return "Selected exact ASIO driver is absent from input/output inventory"; + // For capture B, the OUTPUT name is deliberately EMPTY, never an + // implicit default speaker. Some ASIO vendors reject this outright: + // return REJECT, do NOT invent a dummy output or reopen another driver. + device.reset(asio->createDevice(selected,primary?selected:juce::String())); + if(!device)return "JUCE ASIO refused capture-only device construction"; + juce::BigInteger in,out; + in.setRange(0,primary?2:1,true); + if(primary)out.setRange(0,2,true); + const auto error=device->open(in,out,rate,frames); + if(error.isNotEmpty())return error; + if(!device->isOpen()||device->getName()!=selected) + return "ASIO device opened a different physical driver name"; + if(device->getActiveInputChannels()!=in|| + device->getActiveOutputChannels()!=out) + return "ASIO driver renegotiated physical input or output pin mask"; + if(device->getCurrentSampleRate()<8000. || + device->getCurrentBufferSizeSamples()<=0) + return "ASIO negotiated an invalid rate or period"; + counters.expectedInputs=primary?2:1; + counters.expectedOutputs=primary?2:0; + return {}; + } + void start() { if(device)device->start(&counters); } + bool playing() const {return device&&device->isOpen()&&device->isPlaying();} +}; + +std::uint64_t maskOf(const juce::BigInteger& mask) noexcept +{ + // IO-0 admits only the first 32 ASIO pins; no unsafe truncation of a + // higher sparse physical mask. The fixture checks exact masks below. + if(mask.getHighestBit()>=32)return UINT64_MAX; + return static_cast(mask.getBitRangeAsInt(0,32)); +} + +int probe(const char* primaryLabel,const char* captureLabel,double rate,int frames, + int durationMs) +{ +#if !defined(_WIN32) || !JUCE_ASIO + (void)primaryLabel;(void)captureLabel;(void)rate;(void)frames;(void)durationMs; + std::fputs("IO0_FAIL: pinned Windows JUCE ASIO backend unavailable\n",stderr); + return 3; +#else + // All registry, device enumeration and JUCE open/close calls are CONTROL. + if(!std::isfinite(rate)||rate<8000.||rate>192000.||frames<32|| + frames>8192||durationMs<1000||durationMs>30000) + return 2; + const juce::String primaryName=juce::String::fromUTF8(primaryLabel); + const juce::String captureName=juce::String::fromUTF8(captureLabel); + const auto primaryReg=armix::device::AsioRegistryIdentityProbe::resolve( + std::wstring(primaryName.toWideCharPointer())).registration; + const auto captureReg=armix::device::AsioRegistryIdentityProbe::resolve( + std::wstring(captureName.toWideCharPointer())).registration; + Policy::Request request{std::wstring_view(primaryName.toWideCharPointer()), + std::wstring_view(captureName.toWideCharPointer()), + primaryReg.identity,captureReg.identity,3,3,1}; + const auto initial=Policy::preflight(request); + if(!primaryReg.ok()||!captureReg.ok()||initial!=Policy::Verdict::ok) + { + std::fprintf(stderr,"IO0_REJECT preflight=%s primary=%s capture=%s\n", + Policy::reason(initial), + armix::device::AsioRegistrationPolicy::reason(primaryReg.error), + armix::device::AsioRegistrationPolicy::reason(captureReg.error)); + return 3; + } + Endpoint primary(true),capture(false); + auto err=primary.openExact(primaryName,true,rate,frames); + if(err.isNotEmpty()){std::fprintf(stderr,"IO0_PRIMARY_REJECT %s\n",err.toRawUTF8());return 3;} + // Open primary FIRST, then B while A is still actually open. The primary + // callback is silence-only, not a second mixer render implementation. + primary.start(); + if(!primary.playing()) + {std::fputs("IO0_PRIMARY_START_REJECT\n",stderr);return 3;} + err=capture.openExact(captureName,false,rate,frames); + if(err.isNotEmpty()){std::fprintf(stderr,"IO0_CAPTURE_REJECT %s\n",err.toRawUTF8());return 3;} + const auto primaryRegAfter=armix::device::AsioRegistryIdentityProbe::resolve( + std::wstring(primaryName.toWideCharPointer())).registration; + const auto captureRegAfter=armix::device::AsioRegistryIdentityProbe::resolve( + std::wstring(captureName.toWideCharPointer())).registration; + if(!primaryRegAfter.ok()||!captureRegAfter.ok()|| + !primaryReg.identity.sameDriverClass(primaryRegAfter.identity)|| + !captureReg.identity.sameDriverClass(captureRegAfter.identity)) + {std::fputs("IO0_REJECT ASIO registry class changed while opening\n",stderr);return 3;} + capture.start(); + if(!capture.playing()) + {std::fputs("IO0_CAPTURE_START_REJECT\n",stderr);return 3;} + juce::Thread::sleep(durationMs); // CONTROL only, never the hardware callback + const auto* a=primary.device.get(); + const auto* b=capture.device.get(); + const Policy::Readback readback{ + std::wstring_view(a->getName().toWideCharPointer()), + std::wstring_view(b->getName().toWideCharPointer()), + a->getCurrentSampleRate(),b->getCurrentSampleRate(), + a->getCurrentBufferSizeSamples(),b->getCurrentBufferSizeSamples(), + maskOf(a->getActiveInputChannels()),maskOf(a->getActiveOutputChannels()), + maskOf(b->getActiveInputChannels()),maskOf(b->getActiveOutputChannels())}; + const auto verified=Policy::verify(request,readback); + const auto aCalls=primary.counters.calls.load(); + const auto bCalls=capture.counters.calls.load(); + const auto bSignal=capture.counters.nonzero.load(); + const bool ok=verified==Policy::Verdict::ok&& + primary.playing()&&capture.playing()&&aCalls>0&&bCalls>0&& + bSignal>0&&capture.counters.nonfinite.load()==0&& + !primary.counters.violated.load()&&!capture.counters.violated.load(); + std::printf("IO0_RESULT=%s READBACK=%s PRIMARY_RATE=%.1f CAPTURE_RATE=%.1f " + "PRIMARY_PERIOD=%d CAPTURE_PERIOD=%d PRIMARY_CALLBACKS=%llu " + "CAPTURE_CALLBACKS=%llu CAPTURE_NONZERO_SAMPLES=%llu " + "CAPTURE_OUTPUT_MASK=%llu DSP_PROCESSED=0\n", + ok?"PHYSICAL_PROBE_PASS":"PHYSICAL_PROBE_FAIL",Policy::reason(verified), + readback.primaryRate,readback.captureRate, + readback.primaryPeriod,readback.capturePeriod, + static_cast(aCalls), + static_cast(bCalls), + static_cast(bSignal), + static_cast(readback.captureOutputMask)); + return ok?0:4; +#endif +} +} // namespace + +int main(int argc,char** argv) +{ + // Self-test is deliberately hardware-free; CTest NEVER attempts an + // unknown ASIO device or opens real speakers on an unattended runner. + if(argc==2&&std::string(argv[1])=="--self-test") + { + const Policy::Identity a{L"A",L"{11111111-1111-1111-1111-111111111111}"}; + const Policy::Identity b{L"B",L"{22222222-2222-2222-2222-222222222222}"}; + const Policy::Request r{L"A ASIO",L"B ASIO",a,b,3,3,1}; + if(Policy::preflight(r)!=Policy::Verdict::ok|| + Policy::preflight({L"A ASIO",L"B ASIO",a,a})!= + Policy::Verdict::sameDriverClass) + return 5; + std::puts("IO0_SELF_TEST_PASS: no physical device opened"); + return 0; + } + if(argc!=7||std::string(argv[1])!="--probe") + { + std::fputs("Usage: ARMixDualAsioCaptureProbe --self-test OR\n" + " --probe \"Primary ASIO name\" \"Secondary ASIO name\" " + "48000 256 5000\n" + "WARNING: owner-authorized physical rig only; outputs sent zeros.\n",stderr); + return 2; + } + const double rate=std::strtod(argv[4],nullptr); + const int frames=std::atoi(argv[5]); + const int ms=std::atoi(argv[6]); + return probe(argv[2],argv[3],rate,frames,ms); +} From a154a39a0f8569d2aab9b3f15f05de14c7001f84 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:30:28 +0700 Subject: [PATCH 04/10] fix(io0): hold full endpoint names across readback and query ASIO input inventory correctly --- tools/dual_asio_capture_probe.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp index dc31c81e9..5087c88ba 100644 --- a/tools/dual_asio_capture_probe.cpp +++ b/tools/dual_asio_capture_probe.cpp @@ -85,7 +85,7 @@ struct Endpoint final for(auto* t:factories) if(t->getTypeName()=="ASIO"){asio=t;break;} if(!asio)return "Pinned JUCE build has no ASIO device type"; asio->scanForDevices(); // CONTROL, before opening; never on callback - if(!asio->getDeviceNames(primary).contains(selected) || + if(!asio->getDeviceNames(true).contains(selected) || (primary&&!asio->getDeviceNames(false).contains(selected))) return "Selected exact ASIO driver is absent from input/output inventory"; // For capture B, the OUTPUT name is deliberately EMPTY, never an @@ -140,8 +140,9 @@ int probe(const char* primaryLabel,const char* captureLabel,double rate,int fram std::wstring(primaryName.toWideCharPointer())).registration; const auto captureReg=armix::device::AsioRegistryIdentityProbe::resolve( std::wstring(captureName.toWideCharPointer())).registration; - Policy::Request request{std::wstring_view(primaryName.toWideCharPointer()), - std::wstring_view(captureName.toWideCharPointer()), + const std::wstring primaryWide(primaryName.toWideCharPointer()); + const std::wstring captureWide(captureName.toWideCharPointer()); + Policy::Request request{primaryWide,captureWide, primaryReg.identity,captureReg.identity,3,3,1}; const auto initial=Policy::preflight(request); if(!primaryReg.ok()||!captureReg.ok()||initial!=Policy::Verdict::ok) @@ -176,9 +177,10 @@ int probe(const char* primaryLabel,const char* captureLabel,double rate,int fram juce::Thread::sleep(durationMs); // CONTROL only, never the hardware callback const auto* a=primary.device.get(); const auto* b=capture.device.get(); + const std::wstring openedPrimary(a->getName().toWideCharPointer()); + const std::wstring openedCapture(b->getName().toWideCharPointer()); const Policy::Readback readback{ - std::wstring_view(a->getName().toWideCharPointer()), - std::wstring_view(b->getName().toWideCharPointer()), + openedPrimary,openedCapture, a->getCurrentSampleRate(),b->getCurrentSampleRate(), a->getCurrentBufferSizeSamples(),b->getCurrentBufferSizeSamples(), maskOf(a->getActiveInputChannels()),maskOf(a->getActiveOutputChannels()), From fff803731444639fef35a974d46c344fe8501a2c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:30:53 +0700 Subject: [PATCH 05/10] build(io0): compile native dual-ASIO capture compatibility executable and hardware-free CTest --- CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1819fa29..b65591033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1402,6 +1402,14 @@ if(BUILD_TESTING) add_executable(ARMixIndependentFormatTests tests/independent_stream_format_fence_test.cpp) target_compile_features(ARMixIndependentFormatTests PRIVATE cxx_std_20) add_test(NAME IndependentStreamNegotiatedFormatFence COMMAND ARMixIndependentFormatTests) + # IO-0: pure simultaneous-driver/physical-mask fail-closed policies. + # Existing AdaptiveClockBridge and ClockBridgeSizing are reused, not forked. + add_executable(ARMixIo0DualAsioPolicyTests + tests/dual_asio_capture_probe_policy_test.cpp + engine/device/DualAsioCaptureProbePolicy.h) + target_compile_features(ARMixIo0DualAsioPolicyTests PRIVATE cxx_std_20) + add_test(NAME IO0DualVendorCaptureDriverIdentityAndPhysicalMasks + COMMAND ARMixIo0DualAsioPolicyTests) 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) @@ -1414,6 +1422,22 @@ if(BUILD_TESTING) target_link_libraries(ARMixDualJuceTests PRIVATE juce::juce_audio_devices juce::juce_audio_basics juce::juce_recommended_config_flags) target_compile_features(ARMixDualJuceTests PRIVATE cxx_std_20) add_test(NAME IndependentJuceDeviceLifecycle COMMAND ARMixDualJuceTests) + # Actual pinned JUCE ASIO instance #A + separate zero-output capture B. + # CTest calls --self-test only: unattended CI NEVER opens hardware. + # Physical --probe is opt-in and does NOT run a second mixer renderer. + juce_add_console_app(ARMixDualAsioCaptureProbe + PRODUCT_NAME "ArSonMix Dual ASIO Capture Compatibility Probe") + target_sources(ARMixDualAsioCaptureProbe PRIVATE + tools/dual_asio_capture_probe.cpp + engine/device/DualAsioCaptureProbePolicy.h) + target_compile_definitions(ARMixDualAsioCaptureProbe PRIVATE JUCE_ASIO=1) + target_link_libraries(ARMixDualAsioCaptureProbe PRIVATE + juce::juce_audio_devices juce::juce_audio_basics + juce::juce_recommended_config_flags advapi32) + target_compile_features(ARMixDualAsioCaptureProbe PRIVATE cxx_std_20) + add_test(NAME IO0DualAsioNativeProbeNeverOpensDriversInCI + COMMAND ARMixDualAsioCaptureProbe --self-test) + juce_add_console_app(ARMixWasapiProbeTests PRODUCT_NAME "ArSonMix WASAPI Probe Tests") target_sources(ARMixWasapiProbeTests PRIVATE tests/wasapi_capability_probe_test.cpp engine/device/WasapiCapabilityProbe.h) target_link_libraries(ARMixWasapiProbeTests PRIVATE juce::juce_core ole32 uuid juce::juce_recommended_config_flags) From e06383f63cd74d3fff8373a69f3a02a6f3b5d6a7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:31:28 +0700 Subject: [PATCH 06/10] fix(io0): reuse existing public ASIO device factory enumerator, never instantiate default driver --- tools/dual_asio_capture_probe.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp index 5087c88ba..df0c3880f 100644 --- a/tools/dual_asio_capture_probe.cpp +++ b/tools/dual_asio_capture_probe.cpp @@ -9,6 +9,7 @@ // Explicit manual: ARMixDualAsioCaptureProbe --probe "Vendor A ASIO" "Vendor B ASIO" 48000 256 5000 #include "../engine/device/DualAsioCaptureProbePolicy.h" #include "../engine/device/AsioRegistryIdentityProbe.h" +#include "../engine/device/AsioPriorityDeviceManager.h" #include #include #include @@ -67,7 +68,7 @@ struct CaptureCounters final : juce::AudioIODeviceCallback struct Endpoint final { - juce::AudioDeviceManager discoveryOnly; // never initialise / open defaults + armix::device::AsioPriorityDeviceManager discoveryOnly; // never initialise / open defaults juce::OwnedArray factories; std::unique_ptr device; CaptureCounters counters; From e001211164f9c2278235b3200468c4d60729501e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:33:27 +0700 Subject: [PATCH 07/10] test(io0): keep all native safety assertions active under Release NDEBUG --- tests/dual_asio_capture_probe_policy_test.cpp | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/tests/dual_asio_capture_probe_policy_test.cpp b/tests/dual_asio_capture_probe_policy_test.cpp index 5d05e1ade..047b4aed8 100644 --- a/tests/dual_asio_capture_probe_policy_test.cpp +++ b/tests/dual_asio_capture_probe_policy_test.cpp @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-only #include "../engine/device/DualAsioCaptureProbePolicy.h" #include "../engine/device/ClockBridgeSizing.h" -#include +#include #include #include using Policy=armix::device::DualAsioCaptureProbePolicy; using V=Policy::Verdict; +static void check(bool ok) +{ + // Always active in Release/MSVC CTest; never use NDEBUG-stripped assert. + if (!ok) {std::fputs("IO0_POLICY_FAIL\\n",stderr); std::abort();} +} int main() { @@ -15,45 +20,45 @@ int main() Policy::Request wanted{L"Vendor A ASIO",L"Vendor B ASIO",a,b,3,3,1}; Policy::Readback actual{L"Vendor A ASIO",L"Vendor B ASIO", 48000.,44100.,256,128,3,3,1,0}; - assert(Policy::preflight(wanted)==V::ok); - assert(Policy::verify(wanted,actual)==V::ok); - assert(Policy::preflight({L"Vendor A ASIO",L"Vendor A ASIO",a,a})== + check(Policy::preflight(wanted)==V::ok); + check(Policy::verify(wanted,actual)==V::ok); + check(Policy::preflight({L"Vendor A ASIO",L"Vendor A ASIO",a,a})== V::sameDriverClass); - assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,a})== + check(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,a})== V::sameDriverClass); - assert(Policy::preflight({L"",L"Vendor B ASIO",a,b})== + check(Policy::preflight({L"",L"Vendor B ASIO",a,b})== V::missingSelection); - assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",{},b})== + check(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",{},b})== V::unverifiedPrimaryDriver); - assert(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,{}})== + check(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,{}})== V::unverifiedCaptureDriver); auto changed=actual; changed.captureName=L"USB Audio with same channel names"; - assert(Policy::verify(wanted,changed)==V::wrongCaptureEndpoint); + check(Policy::verify(wanted,changed)==V::wrongCaptureEndpoint); changed=actual; changed.primaryName=L"Unexpected output"; - assert(Policy::verify(wanted,changed)==V::wrongPrimaryEndpoint); + check(Policy::verify(wanted,changed)==V::wrongPrimaryEndpoint); changed=actual; changed.primaryOutputMask=1; - assert(Policy::verify(wanted,changed)==V::primaryOutputMissing); + check(Policy::verify(wanted,changed)==V::primaryOutputMissing); changed=actual; changed.primaryInputMask=1; - assert(Policy::verify(wanted,changed)==V::primaryMaskChanged); + check(Policy::verify(wanted,changed)==V::primaryMaskChanged); changed=actual; changed.captureInputMask=0; - assert(Policy::verify(wanted,changed)==V::captureInputMissing); + check(Policy::verify(wanted,changed)==V::captureInputMissing); changed=actual; changed.captureOutputMask=3; - assert(Policy::verify(wanted,changed)==V::captureOutputUnexpected); + check(Policy::verify(wanted,changed)==V::captureOutputUnexpected); changed=actual; changed.captureInputMask=2; - assert(Policy::verify(wanted,changed)==V::captureMaskChanged); + check(Policy::verify(wanted,changed)==V::captureMaskChanged); changed=actual; changed.captureRate=0; - assert(Policy::verify(wanted,changed)==V::invalidFormat); + check(Policy::verify(wanted,changed)==V::invalidFormat); changed=actual; changed.primaryPeriod=0; - assert(Policy::verify(wanted,changed)==V::invalidFormat); + check(Policy::verify(wanted,changed)==V::invalidFormat); // Reuse production ASRC sizing. Different clocks always need a bounded // prepared source bridge in IO-1; IO-0 does not insert one into primary. @@ -62,13 +67,13 @@ int main() { const auto sizing=armix::device::ClockBridgeSizing::choose( source,primary,128,256,48,32768,24.); - assert(sizing.valid); - assert(sizing.targetMs>=24.); - assert(sizing.minFrames>0); + check(sizing.valid); + check(sizing.targetMs>=24.); + check(sizing.minFrames>0); } const auto impossible=armix::device::ClockBridgeSizing::choose( 48000.,48000.,32768,32768,48,32768,24.); - assert(!impossible.valid); + check(!impossible.valid); std::puts("IO0_POLICY_PASS: identity, zero-output capture, exact masks, 9 clock profiles"); return 0; } From 089ae026cf8f87dc5b99bb69001f73eb347564e2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:38:03 +0700 Subject: [PATCH 08/10] fix(io0 safety): pass JUCE output-then-input names; capture-only never selects an output --- tools/dual_asio_capture_probe.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp index df0c3880f..2bcf0479d 100644 --- a/tools/dual_asio_capture_probe.cpp +++ b/tools/dual_asio_capture_probe.cpp @@ -92,7 +92,9 @@ struct Endpoint final // For capture B, the OUTPUT name is deliberately EMPTY, never an // implicit default speaker. Some ASIO vendors reject this outright: // return REJECT, do NOT invent a dummy output or reopen another driver. - device.reset(asio->createDevice(selected,primary?selected:juce::String())); + // JUCE createDevice signature is (OUTPUT name, INPUT name). + // B MUST have no output device even during construction. + device.reset(asio->createDevice(primary?selected:juce::String(),selected)); if(!device)return "JUCE ASIO refused capture-only device construction"; juce::BigInteger in,out; in.setRange(0,primary?2:1,true); From 741afa336b1cb74b5a12ec77858f47f6d87eafac Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 06:41:05 +0700 Subject: [PATCH 09/10] fix(io0): initialise JUCE message/ASIO device lifecycle only for opted-in hardware probe --- tools/dual_asio_capture_probe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp index 2bcf0479d..d905c3254 100644 --- a/tools/dual_asio_capture_probe.cpp +++ b/tools/dual_asio_capture_probe.cpp @@ -239,5 +239,9 @@ int main(int argc,char** argv) const double rate=std::strtod(argv[4],nullptr); const int frames=std::atoi(argv[5]); const int ms=std::atoi(argv[6]); + // ASIO uses JUCE message-window/COM lifecycle for reset notifications. + // The attended physical probe initialises it on CONTROL only; --self-test + // deliberately never creates a MessageManager or opens a sound device. + juce::ScopedJuceInitialiser_GUI initialiseJuce; return probe(argv[2],argv[3],rate,frames,ms); } From fbb94438b7605687600708e8bdac4a0daf430d8f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 07:22:02 +0700 Subject: [PATCH 10/10] fix(io0): preserve mutable JUCE AudioIODevice readback APIs under MSVC --- tools/dual_asio_capture_probe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dual_asio_capture_probe.cpp b/tools/dual_asio_capture_probe.cpp index d905c3254..9dded0d58 100644 --- a/tools/dual_asio_capture_probe.cpp +++ b/tools/dual_asio_capture_probe.cpp @@ -178,8 +178,8 @@ int probe(const char* primaryLabel,const char* captureLabel,double rate,int fram if(!capture.playing()) {std::fputs("IO0_CAPTURE_START_REJECT\n",stderr);return 3;} juce::Thread::sleep(durationMs); // CONTROL only, never the hardware callback - const auto* a=primary.device.get(); - const auto* b=capture.device.get(); + auto* a=primary.device.get(); + auto* b=capture.device.get(); const std::wstring openedPrimary(a->getName().toWideCharPointer()); const std::wstring openedCapture(b->getName().toWideCharPointer()); const Policy::Readback readback{