Repository navigation
feat(io0): real dual-vendor ASIO primary + capture-only compatibility probe #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
masarray
merged 10 commits into
main
from
feat/io0-dual-asio-capture-feasibility-20261118
Nov 18, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
34157c0
feat(io0): add fail-closed dual-ASIO capture readback and driver clas…
masarray 20cfdb2
test(io0): reject wrong driver, capture output, sparse mask mismatche…
masarray 5f63177
feat(io0): real opt-in dual ASIO primary+capture-only JUCE driver pro…
masarray a154a39
fix(io0): hold full endpoint names across readback and query ASIO inp…
masarray fff8037
build(io0): compile native dual-ASIO capture compatibility executable…
masarray e06383f
fix(io0): reuse existing public ASIO device factory enumerator, never…
masarray e001211
test(io0): keep all native safety assertions active under Release NDEBUG
masarray 089ae02
fix(io0 safety): pass JUCE output-then-input names; capture-only neve…
masarray 741afa3
fix(io0): initialise JUCE message/ASIO device lifecycle only for opte…
masarray fbb9443
fix(io0): preserve mutable JUCE AudioIODevice readback APIs under MSVC
masarray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-only | ||
| #pragma once | ||
| #include "AsioRegistrationPolicy.h" | ||
| #include <cmath> | ||
| #include <cstdint> | ||
| #include <string_view> | ||
|
|
||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-only | ||
| #include "../engine/device/DualAsioCaptureProbePolicy.h" | ||
| #include "../engine/device/ClockBridgeSizing.h" | ||
| #include <cstdlib> | ||
| #include <cstdio> | ||
| #include <string_view> | ||
|
|
||
| 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() | ||
| { | ||
| 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}; | ||
| 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); | ||
| check(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",a,a})== | ||
| V::sameDriverClass); | ||
| check(Policy::preflight({L"",L"Vendor B ASIO",a,b})== | ||
| V::missingSelection); | ||
| check(Policy::preflight({L"Vendor A ASIO",L"Vendor B ASIO",{},b})== | ||
| V::unverifiedPrimaryDriver); | ||
| 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"; | ||
| check(Policy::verify(wanted,changed)==V::wrongCaptureEndpoint); | ||
| changed=actual; | ||
| changed.primaryName=L"Unexpected output"; | ||
| check(Policy::verify(wanted,changed)==V::wrongPrimaryEndpoint); | ||
| changed=actual; | ||
| changed.primaryOutputMask=1; | ||
| check(Policy::verify(wanted,changed)==V::primaryOutputMissing); | ||
| changed=actual; | ||
| changed.primaryInputMask=1; | ||
| check(Policy::verify(wanted,changed)==V::primaryMaskChanged); | ||
| changed=actual; | ||
| changed.captureInputMask=0; | ||
| check(Policy::verify(wanted,changed)==V::captureInputMissing); | ||
| changed=actual; | ||
| changed.captureOutputMask=3; | ||
| check(Policy::verify(wanted,changed)==V::captureOutputUnexpected); | ||
| changed=actual; | ||
| changed.captureInputMask=2; | ||
| check(Policy::verify(wanted,changed)==V::captureMaskChanged); | ||
| changed=actual; | ||
| changed.captureRate=0; | ||
| check(Policy::verify(wanted,changed)==V::invalidFormat); | ||
| changed=actual; | ||
| changed.primaryPeriod=0; | ||
| 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. | ||
| 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.); | ||
| 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.); | ||
| check(!impossible.valid); | ||
| std::puts("IO0_POLICY_PASS: identity, zero-output capture, exact masks, 9 clock profiles"); | ||
| return 0; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When two differently named ASIO registrations point to the same CLSID, this preflight accepts them because
Identity::sameDriverClass()requires both the registry key and CLSID to match. A local policy reproduction with different names/keys but identical CLSIDs returnsIO0_EXACT_ASIO_READBACK. Such aliases instantiate the same driver class, so they do not satisfy this probe's distinct-class prerequisite and may produce misleading dual-vendor qualification. Compare canonical CLSIDs directly for this rejection, while retaining the stricter registration comparison for before/after identity checks. AGENTS.md requires driver identity verification and separately proven multi-device compatibility.AGENTS.md reference: AGENTS.md:L37-L37
Useful? React with 👍 / 👎.