The previous commit let the main input stream format select a layout, but
persisted only its output channel count. Everything downstream re-derives
the layout from that count through `layout_for_output`, which takes the
first match — so for a plugin whose layouts share an output count but
differ on the input side, e.g. [{in:2,out:2}, {in:1,out:2}], setting the
input to 1 channel returned noErr while the derivation still landed on
{2,2}. The wrapper reported success for a format it would not honor;
before the relaxation this case was rejected.
Accept a selection only when `layout_for_output` resolves back to the same
layout. Symmetric layouts — the shape every stock example plugin and the
AU-supported configuration use — are unaffected.
Also correcting an overclaim in the previous commit message: single-layout
plugins are unaffected only when their output count is 2. A mono-only
plugin still cannot negotiate input-first, because `n_channels` starts at
a hardcoded 2 and `current_layout(2)` finds nothing, so the input branch
returns InvalidElement before the new lookup is reachable. That is
pre-existing, not a regression — but the fix makes declared layouts
reachable from a resolvable starting state, not in general.
The new test returns noErr instead of -10868 when the round-trip check is
removed.
문제
AU 래퍼의
kAudioUnitProperty_StreamFormat입력 스코프 처리가 요청 채널 수를 "지금 출력 채널 수가 함의하는 레이아웃"에만 대조했다:두 사실이 겹치면서 출력 스코프를 먼저 세팅하지 않는 호스트에게는 두 번째 레이아웃이 존재하지 않는 것이 된다:
n_channels는 생성 시2로 하드코딩된다 (wrapper.rs:542) — 레이아웃 배열의 index 0 이 아니다.layout_for_output은main_output_channels만 본다. 입력 쪽은 선택에 관여하지 못하고 검증만 당한다.AU 는 채널 포맷을 스코프 하나씩 협상하고 호스트마다 순서가 다르다.
auval의 채널 테스트는 입력 포맷을 먼저 1ch 로 세팅한다 — 그 순간 레이아웃은 아직{2,2}라expected=2 != 1→ 거절, 이후 렌더 준비가-10868로 죽는다.{2,2}+{1,1}을 선언한 이펙트(=plugins/examples/gain을 포함해 스톡 예제들이 쓰는 바로 그 모양)에서 실측:능력 광고와 채널 핸들링 매트릭스는 정상이다. 죽는 곳은 렌더 준비다.
수정
메인 입력 버스도 출력 버스와 똑같이 레이아웃을 선택하게 한다 (
layout_for_main_input추가). 출력 채널 수를 함께 옮긴다.경계 조건 — "아무거나 수용"이 되지 않게 하는 것들:
main_input_channels: None인 인스트루먼트는is_main_input이 false 라 경로에 들어오지 않는다.is_initialized()가드) 렌더 스레드와 경합하지 않는다.n_channels저장은 출력 분기가 이미 쓰던 것과 같은 atomic·같은 ordering 이다.검증
{2,2}+{1,1}이펙트 대상): 입력 우선 협상이 레이아웃을 옮기는지, 미선언 채널 수는 여전히 거절하는지, 출력 스코프 선택이 그대로인지.main_input_stream_format_selects_a_matching_layout가left: -10868 / right: 0으로 실패한다 —auval이 낸 것과 같은 오류 코드다.cargo test -p nih_plug --features au --lib125 passed.auval(소비자 de-artifact, macOS 26,.app래핑 +-oop): 수정 후 PASS —1 Channel Test: Render Test at 512 frames → PASS. 스테레오 렌더 테스트도 그대로 통과.남는 것 (이 PR 범위 밖)
auval이WARNING: Can Initialize Unit to un-supported num channels:InputChan:1, OutputChan:2를 낸다. 섹션도 전체도 PASS 다. 래퍼가 마지막으로 세팅된 입력 채널 수를 따로 기억하지 않아Initialize에서 교차검증을 못 하기 때문인데, 고치려면 Initialize 단계 검증을 새로 넣어야 한다 — 포맷 세팅 순서가 제각각인 실제 호스트에서 "AU 초기화 실패"라는 새 실패 계열을 만들 위험이 WARNING 하나보다 크다고 보고 별도로 남긴다.관련: de-artifact AUD-1278 (모노 레이아웃), AUD-1259 (포크 분기 정리)