diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 706619cce..7e55d92d4 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -140,7 +140,7 @@ jobs: node --check web/plugin-ui.js node --check web/mixer-io.js node --check web/mixer-layout.js - node --test tests/workstream_coordination_contract.test.mjs tests/gui_workflow_contract_test.mjs tests/plugin_ui_contract_test.mjs tests/ci_workflow_efficiency_test.mjs tests/fx_drag_reorder_contract_test.mjs tests/mixer_io_operator_contract_test.mjs tests/mixer_shell_contract_test.mjs tests/approved_native_m2_contract.test.cjs + node --test tests/workstream_coordination_contract.test.mjs tests/gui_workflow_contract_test.mjs tests/plugin_ui_contract_test.mjs tests/ci_workflow_efficiency_test.mjs tests/fx_drag_reorder_contract_test.mjs tests/mixer_io_operator_contract_test.mjs tests/mixer_shell_contract_test.mjs tests/approved_native_m2_contract.test.cjs tests/p1_stream_wire_fx_contract.test.cjs - name: Validate approved GUI checkpoint and single publisher run: python tests/gui_baseline_lock_test.py - name: CSS V28 zero-regression source-order recovery (every GUI CI run) @@ -166,6 +166,10 @@ jobs: run: python tests/approved_native_meter_dirty_stage_b_smoke.py - name: Verify Stage C shipped CSS versus original-source computed and screenshot parity run: python tests/approved_stage_c_css_visual_parity_smoke.py + - name: Check real mobile /preview/ touch toolbar, popup and stray chevrons + run: python tests/approved_preview_mobile_navigation_smoke.py + - name: FX rack master bypass preserves each insert state (real Chromium) + run: python tests/approved_fx_rack_master_power_smoke.py - name: Stage D one runtime CSSOM and actual stylesheet network count run: python tests/approved_css_stage_d_single_bundle_smoke.py - name: Stage C rendered CSS parity (original vs compiled, three viewports + hover) @@ -448,5 +452,6 @@ jobs: pages-v54-*.png pages-v55-*.png pages-v28-physical-console-owner-v59-*.png + pages-mobile-*.png if-no-files-found: ignore retention-days: 3 diff --git a/engine/core/DynamicChannelFxLeaseBank.h b/engine/core/DynamicChannelFxLeaseBank.h index 46c29f4f8..36499a531 100644 --- a/engine/core/DynamicChannelFxLeaseBank.h +++ b/engine/core/DynamicChannelFxLeaseBank.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -33,6 +35,9 @@ class DynamicChannelFxLeaseBank final { ChannelId id{}; ProcessingFormat format=ProcessingFormat::stereo; std::vector inserts; // CONTROL only; no creation on callback + // Reused over revision changes. This flag overrides the effective + // output without changing the individual FxInstance bypass flags. + std::shared_ptr> rackBypassed; }; // Occupied CH1 vendor/Orbit owner remains alive with accepted PCM. @@ -101,6 +106,8 @@ class DynamicChannelFxLeaseBank final { if(b.format!=ProcessingFormat::mono && b.format!=ProcessingFormat::stereo)return Fault::invalidBusLayout; Row row;row.id=b.id;row.format=b.format; + row.rackBypassed=b.rackBypassed?b.rackBypassed: + std::make_shared>(false); // CONTROL allocation row.count=static_cast(b.inserts.size()); for(std::size_t i=0;ibypassRequested.store(bypass,std::memory_order_release); return true; } + bool setRackBypass(std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,ChannelId id, + bool bypass) const noexcept { + if(expectedEpoch!=epoch_||expectedRevision!=revision_||!id.value) + return false; + const auto* row=find(id); + if(!row||!row->rackBypassed)return false; + row->rackBypassed->store(bypass,std::memory_order_release); + return true; + } + bool rackBypassed(ChannelId id) const noexcept { + const auto* row=find(id); + return row&&row->rackBypassed && + row->rackBypassed->load(std::memory_order_acquire); + } // The actual prepared vendor instance is also the native editor owner; // never synthesize a WebView editor or use a catalog name as identity. Lease leaseEditor(std::uint64_t expectedEpoch, @@ -199,7 +221,7 @@ class DynamicChannelFxLeaseBank final { retained.reserve(prior.rows_.size()); for(const auto& row:prior.rows_) { Assignment item; - item.id=row.id;item.format=row.format; + item.id=row.id;item.format=row.format;item.rackBypassed=row.rackBypassed; item.inserts.reserve(row.count); for(std::size_t slot=0;slotrackBypassed && + row->rackBypassed->load(std::memory_order_acquire); for(std::size_t i=0;icount;++i) - row->raw[i]->render(left,right,frames); + row->raw[i]->render(left,right,frames,rackOff); } private: @@ -262,6 +287,7 @@ class DynamicChannelFxLeaseBank final { ChannelId id{}; ProcessingFormat format=ProcessingFormat::stereo; std::uint8_t count=0; + std::shared_ptr> rackBypassed; // persists across revisions std::array owners{}; std::array raw{}; }; diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 281b172f9..7bd2ba0e4 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -79,7 +79,7 @@ class LiveChannelFxGraph final { processing.clear(std::memory_order_release); return ok; } - void render(float* left,float* right,int samples) noexcept { + void render(float* left,float* right,int samples,bool rackBypassed=false) noexcept { if(processing.test_and_set(std::memory_order_acquire)) { contention.fetch_add(1,std::memory_order_relaxed); juce::FloatVectorOperations::clear(left,samples); @@ -87,7 +87,8 @@ class LiveChannelFxGraph final { return; } // G5C: atomic request from control; fade and scratch RT-owned. - bypassFade.request(bypassRequested.load(std::memory_order_relaxed)); + // Master rack bypass affects the WET/DRY envelope, never the remembered insert preference. + bypassFade.request(rackBypassed || bypassRequested.load(std::memory_order_relaxed)); if(bypassFade.fullyBypassed()) { processing.clear(std::memory_order_release); return; @@ -227,6 +228,17 @@ class LiveChannelFxGraph final { fx->bypassRequested.store(bypass,std::memory_order_release); return true; } + // One atomic rack override per channel. Individual slot bypass flags stay + // unchanged; ON restores the previous enabled/disabled combination. + bool setRackBypass(int strip,bool bypass) noexcept { + if(strip<0||strip>=fxSlots)return false; + rackBypassed_[strip].store(bypass,std::memory_order_release); + return true; + } + bool rackBypassed(int strip) const noexcept { + return strip>=0&&stripcatalogId!=catalogId)return false; for(int i=0;i=fxSlots)return; const int count=counts_[strip]; // immutable, prepared OFF RT + const bool rackOff=rackBypassed_[strip].load(std::memory_order_acquire); if(count>0) { for(int slot=0;slotrender(l,r,samples); // no shared_ptr copies or RT heap use + instance->render(l,r,samples,rackOff); // existing 8ms fade; no RT allocation } } else if(strip==0 && externalFx) + // The legacy CH1 callback owns its own per-slot smooth rack + // bypass. Never skip it abruptly or strip out its FX tail. externalFx(externalContext,strip,l,r,samples); }; if(monitorEnabled_ && (!monitorL||!monitorR))return false; @@ -315,6 +334,7 @@ class LiveChannelFxGraph final { RealtimeStripControls controls_ {}; FxBank processors_ {}; std::array counts_ {}; + std::array,fxSlots> rackBypassed_{}; // CONTROL write; one RT read per lane int activeInserts_=0; int pluginQuantum_=512; int mainOutputLeft_=0,mainOutputRight_=1; diff --git a/engine/core/UnifiedLegacyProductionAdmission.h b/engine/core/UnifiedLegacyProductionAdmission.h index 37d431806..e82a86b55 100644 --- a/engine/core/UnifiedLegacyProductionAdmission.h +++ b/engine/core/UnifiedLegacyProductionAdmission.h @@ -59,6 +59,12 @@ struct UnifiedLegacyAccepted final { fxOwners->setInsertBypass(epoch,revision,id,slot, instanceId,bypass); } + bool setFxRackBypass(const DynamicNativeSessionPublisher& publisher, + std::uint64_t epoch,std::uint64_t revision, + ChannelId id,bool bypass) const noexcept { + return matches(publisher,epoch,revision) && + fxOwners->setRackBypass(epoch,revision,id,bypass); + } DynamicChannelFxLeaseBank::Lease leaseFxEditor( const DynamicNativeSessionPublisher& publisher, std::uint64_t epoch,std::uint64_t revision,ChannelId id, diff --git a/integration/ApprovedNativeControlIntent.h b/integration/ApprovedNativeControlIntent.h index e5062b9a3..6773c6799 100644 --- a/integration/ApprovedNativeControlIntent.h +++ b/integration/ApprovedNativeControlIntent.h @@ -9,6 +9,8 @@ #include #include #include +#include +#include // INTEGRATOR M3-B: bridge the approved /preview/ control ABI to the ONE // native ChannelId PCM owner from ENGINE #266. Translation is CONTROL-thread @@ -68,6 +70,108 @@ inline ApprovedNativeControlIntent translateApprovedNativeControl( return reject("STALE_NATIVE_CONTROL_REVISION"); if(!request.isString() || request.toString().isEmpty() || request.toString().length()>128)return reject("INVALID_REQUEST_ID"); + // P1 WIRE: the previous GUI emitted APPLY_WIRE_TRANSACTION, but this + // translator accepted only fader/pan/mute/solo and silently left native + // BUS routing unavailable. Validate the exact accepted ChannelId/EdgeId + // inventory and public+native capabilities BEFORE compiling any changes. + if(op=="APPLY_WIRE_TRANSACTION") { + if(!approvedHasOperation(caps.getProperty("supportedOps",{}), + "APPLY_WIRE_TRANSACTION") || + !approvedHasOperation(installedBus.getProperty("supportedOps",{}), + "NATIVE_APPLY_WIRE_TRANSACTION")) + return reject("NATIVE_WIRE_NOT_ADMITTED"); + juce::var owner,producer; + for(const auto& row:*rows.getArray()) + if(row.getProperty("id","").toString()==ids.toString())owner=row; + for(const auto& row:*nativeRows.getArray()) + if(row.getProperty("id","").toString()==ids.toString())producer=row; + if(!owner.isObject()||!producer.isObject()|| + owner.getProperty("role","").toString()!= + producer.getProperty("role","").toString()) + return reject("WIRE_SOURCE_NOT_ADMITTED"); + const auto sourceRole=owner.getProperty("role","").toString(); + if(sourceRole!="INPUT"&&sourceRole!="GROUP"&&sourceRole!="FX_RETURN") + return reject("WIRE_INVALID_SOURCE_ROLE"); + const auto sourcePayload=publicIntent.getProperty("payload",{}); + const auto rawChanges=sourcePayload.getProperty("changes",{}); + const auto* changes=rawChanges.getArray(); + if(!changes||changes->isEmpty()||changes->size()>64) + return reject("WIRE_INVALID_BATCH"); + const auto pubEdges=graph.getProperty("edges",{}); + const auto nativeEdges=installedBus.getProperty("edges",{}); + if(!pubEdges.isArray()||!nativeEdges.isArray()) + return reject("WIRE_EDGE_INVENTORY_UNAVAILABLE"); + juce::Array verified; + for(const auto& edit:*changes) { + if(!edit.isObject())return reject("WIRE_INVALID_EDIT"); + const auto kind=edit.getProperty("op","").toString(); + const auto from=edit.getProperty("from",{}); + if(from.toString()!=ids.toString()|| + (kind!="CONNECT" && kind!="REMOVE" && + kind!="RETARGET" && kind!="ROUTE_ONLY")) + return reject("WIRE_SOURCE_OR_OPERATION_INVALID"); + auto item=std::make_unique(); + item->setProperty("op",kind); + item->setProperty("from",ids); + if(kind=="REMOVE" || kind=="RETARGET") { + const auto edgeId=edit.getProperty("edgeId",{}); + if(!nativeV8Decimal(edgeId))return reject("WIRE_EDGE_ID_INVALID"); + bool pubFound=false,nativeFound=false; + for(const auto& e:*pubEdges.getArray()) + if(e.getProperty("edgeId","").toString()==edgeId.toString() && + e.getProperty("from","").toString()==ids.toString()) + pubFound=true; + for(const auto& e:*nativeEdges.getArray()) + if(e.getProperty("edgeId","").toString()==edgeId.toString() && + e.getProperty("from","").toString()==ids.toString()) + nativeFound=true; + if(!pubFound||!nativeFound)return reject("WIRE_STALE_EDGE"); + item->setProperty("edgeId",edgeId); + } + if(kind=="CONNECT" || kind=="RETARGET" || kind=="ROUTE_ONLY") { + const auto to=edit.getProperty("to",{}); + if(!nativeV8Decimal(to) || to.toString()==ids.toString()) + return reject("WIRE_INVALID_DESTINATION"); + juce::String role; + bool nativeFound=false; + for(const auto& row:*rows.getArray()) + if(row.getProperty("id","").toString()==to.toString()) + role=row.getProperty("role","").toString(); + for(const auto& row:*nativeRows.getArray()) + if(row.getProperty("id","").toString()==to.toString()) + nativeFound=true; + if(!nativeFound || + (role!="GROUP"&&role!="FX_RETURN"&&role!="MAIN")) + return reject("WIRE_UNSUPPORTED_DESTINATION"); + // The roster's ROUTE_ONLY decoder explicitly forbids MAIN; + // choosing MAIN requires a native primary-output operation. + if(kind=="ROUTE_ONLY"&&role=="MAIN") + return reject("WIRE_MAIN_PRIMARY_REQUIRED"); + item->setProperty("to",to); + } + if(kind=="CONNECT" || kind=="ROUTE_ONLY") { + double gain=0.; + if(edit.getProperty("tap","").toString()!="POST_FADER" || + !nativeV8Number(edit.getProperty("gainLinear",{}),gain) || + gain<0.||gain>4.|| + (kind=="ROUTE_ONLY"&&gain!=1.)) + return reject("WIRE_UNSUPPORTED_TAP_OR_GAIN"); + item->setProperty("gainLinear",gain); + } + verified.add(juce::var(item.release())); + } + auto payload=std::make_unique(); + payload->setProperty("changes",juce::var(verified)); + auto converted=std::make_unique(); + converted->setProperty("requestId",request); + converted->setProperty("deviceEpoch",epoch); + converted->setProperty("baseGraphRevision",revision); + converted->setProperty("baseRosterRevision",roster); + converted->setProperty("targetChannelId",ids); + converted->setProperty("operation","NATIVE_APPLY_WIRE_TRANSACTION"); + converted->setProperty("payload",juce::var(payload.release())); + return {juce::var(converted.release()),{}}; + } if(op!="SET_FADER" && op!="SET_PAN" && op!="SET_MUTE" && op!="SET_SOLO")return reject("UNSUPPORTED_APPROVED_CONTROL"); // Both native *and* GUI-side capabilities must be explicitly advertised @@ -203,6 +307,56 @@ inline bool executeApprovedNativeControl(Engine& engine, if(!payload.isObject())return false; const auto operation=translated.getProperty("operation","").toString(); const auto channel=armix::mixer::ChannelId{id}; + if(operation=="NATIVE_APPLY_WIRE_TRANSACTION") { + const raw=payload.getProperty("changes",{}); + const auto* edits=raw.getArray(); + if(!edits||edits->isEmpty()||edits->size()>64)return false; + std::vector changes; + changes.reserve(static_cast(edits->size())); + for(const auto& edit:*edits) { + if(!edit.isObject())return false; + const auto op=edit.getProperty("op","").toString(); + std::uint64_t from=0,to=0,edgeId=0; + if(!approvedNativeId(edit.getProperty("from",{}),from) || from!=id) + return false; + armix::mixer::WireChange change; + change.from=armix::mixer::ChannelId{from}; + if(op=="CONNECT")change.kind=armix::mixer::WireChange::Kind::connect; + else if(op=="REMOVE")change.kind=armix::mixer::WireChange::Kind::remove; + else if(op=="RETARGET")change.kind=armix::mixer::WireChange::Kind::retarget; + else if(op=="ROUTE_ONLY")change.kind=armix::mixer::WireChange::Kind::routeOnly; + else return false; + if(op=="CONNECT"||op=="RETARGET"||op=="ROUTE_ONLY") { + if(!approvedNativeId(edit.getProperty("to",{}),to)||to==from) + return false; + change.to=armix::mixer::ChannelId{to}; + } + if(op=="REMOVE"||op=="RETARGET") { + if(!approvedNativeId(edit.getProperty("edgeId",{}),edgeId)) + return false; + change.edgeId=edgeId; + } + if(op=="CONNECT"||op=="ROUTE_ONLY") { + double gain=0.; + if(!nativeV8Number(edit.getProperty("gainLinear",{}),gain) || + gain<0.||gain>4.|| + (op=="ROUTE_ONLY"&&gain!=1.)) + return false; + change.gain=static_cast(gain); + } + changes.push_back(change); + } + // The real engine may still reject while monitoring/output is armed. + // Never auto-mute, fabricate a JS graph, or bypass its safety fence. + if constexpr(requires(Engine& e, std::span values) { + e.applyNativeWireTransaction(epoch,revision,roster,values); + }) { + const auto applied=engine.applyNativeWireTransaction( + epoch,revision,roster, + std::span(changes)); + return applied.accepted && applied.error.isEmpty(); + } else return false; + } if(operation=="NATIVE_SET_CHANNEL_MIX" || operation=="NATIVE_SET_BUS_MIX") { const auto rawGain=payload.getProperty("gain",{}); diff --git a/scripts/approved_fx_rack_power.py b/scripts/approved_fx_rack_power.py new file mode 100644 index 000000000..5bbad92d3 --- /dev/null +++ b/scripts/approved_fx_rack_power.py @@ -0,0 +1,32 @@ +"""Approved single-GUI FX rack power semantics, injected at the ONE Pages build. + +The historical V28 source HTML is immutable. Apply exactly TWO audited +semantic substitutions to its JavaScript when assembling both public /preview/ +and native JUCE WebView2. No additional stylesheet, second state store, or +private fork of the mixer. t.fxOn is rack authority, slotBypass[] is the +preserved per-insert preference. Effective = fxOn && !slotBypass[i]. +""" +def apply_authoritative_fx_power(html: str) -> str: + substitutions = [ + ( + "name==='None'?'is-empty':t.slotBypass[i]?'is-bypassed':'is-active'", + "name==='None'?'is-empty':(!t.fxOn||t.slotBypass[i])?'is-bypassed':'is-active'", + ), + ( + 'aria-pressed="\'+Boolean(!t.slotBypass[i])+\'">', + 'aria-pressed="\'+Boolean(t.fxOn&&!t.slotBypass[i])+\'">', + ), + ( + "title=\"'+(t.slotBypass[i]?'Enable':'Bypass')+' only insert", + "title=\"'+(!t.fxOn?'Rack bypassed, saved '+(t.slotBypass[i]?'OFF':'ON'):t.slotBypass[i]?'Enable':'Bypass')+' only insert", + ), + ( + "aria-label=\"'+(t.slotBypass[i]?'Enable':'Bypass')+' only FX insert", + "aria-label=\"'+(!t.fxOn?'Rack bypassed, saved '+(t.slotBypass[i]?'OFF':'ON'):t.slotBypass[i]?'Enable':'Bypass')+' only FX insert", + ), + ] + for before, after in substitutions: + if html.count(before) != 1: + raise ValueError("FX master semantics anchor missing or ambiguous: " + before[:90]) + html=html.replace(before,after,1) + return html diff --git a/scripts/build_pages.py b/scripts/build_pages.py index e0e92b0c3..df0937e67 100644 --- a/scripts/build_pages.py +++ b/scripts/build_pages.py @@ -2,6 +2,7 @@ from pathlib import Path import argparse,os,json,shutil,subprocess,sys from compile_approved_css import optimize_assets +from approved_fx_rack_power import apply_authoritative_fx_power ROOT=Path(__file__).resolve().parents[1] p=argparse.ArgumentParser() p.add_argument('--out',default='dist-pages') @@ -59,6 +60,7 @@ if canonical_html.count('')!=1 or probe_tag in canonical_html: raise SystemExit('Approved Pages profiler injection must have exactly one body') canonical_html=canonical_html.replace('',probe_tag+'\n',1) +canonical_html=apply_authoritative_fx_power(canonical_html) # Stage C: compile only DEPLOYED copies, never modify locked V28 source # owners or approved PNG artwork. No new CSS/override or second renderer. canonical_html,css_compilation=optimize_assets(canonical_html,buttons_dest/'assets',runtime_bundle=True) diff --git a/scripts/compile_approved_css.py b/scripts/compile_approved_css.py index 0410dca59..dfb6048c3 100644 --- a/scripts/compile_approved_css.py +++ b/scripts/compile_approved_css.py @@ -18,7 +18,10 @@ from pathlib import Path import re -LINK = re.compile(r'(. Stage D removes 17 links; +# matching only their closing quote left 18 literal '>' rendered above the GUI, +# most visibly in mobile viewport. Preserve all attributes/order fail-closed. +LINK = re.compile(r'()', re.I) PROPERTY = re.compile(r"^\s*(--[A-Za-z0-9_-]+|[-A-Za-z_][-A-Za-z0-9_]*)\s*:", re.S) IMPORTANT = re.compile(r"!\s*important\s*$", re.I) CONTAINER = re.compile(r"^@(media|supports|container|layer|scope)(?=\s|\()", re.I) diff --git a/site/preview-v2/assets/mixer-console-foundation.css b/site/preview-v2/assets/mixer-console-foundation.css index c79bee3f8..d738f7a98 100644 --- a/site/preview-v2/assets/mixer-console-foundation.css +++ b/site/preview-v2/assets/mixer-console-foundation.css @@ -6,7 +6,7 @@ font:11px/1.32 "Segoe UI",Arial,sans-serif; } *{box-sizing:border-box} -html,body{width:100%;height:100%;min-width:760px;min-height:540px;margin:0;overflow:hidden;background:#202123;color:var(--ink)} +html,body{width:100%;height:100%;min-width:min(760px,100%);min-height:540px;margin:0;overflow:hidden;background:#202123;color:var(--ink)} button,input,select{font:inherit;color:inherit} button{cursor:pointer} button:focus-visible,input:focus-visible,select:focus-visible{outline:1px solid #8cc5da;outline-offset:-1px} @@ -31,4 +31,30 @@ button:disabled{opacity:.45;cursor:not-allowed} .mixer-title .accent{height:12px;width:3px;background:#55afcb} .mixer-title .panel-name{font-weight:600} .mixer-title .panel-sub{color:#8f9295} -.mixer-title .right{margin-left:auto;color:#808488;font-size:10px} \ No newline at end of file +.mixer-title .right{margin-left:auto;color:#808488;font-size:10px} + +/* Official /preview/ on phone: the desktop console remains a real, scrollable + mixer, not a second mobile skin. All selectors belong to this foundation + owner; no CSS override file, repeated > arrows or changed desktop controls. + More stays reachable, and its popup must not be clipped by toolbar scroll. */ +@media (max-width:759px){ + .app .window-title{min-width:0;gap:8px;overflow:hidden} + .app .window-title .study{display:none} + .app .window-title .file-name{min-width:0;max-width:55vw;overflow:hidden;text-overflow:ellipsis} + .app .command-bar{ + max-width:100%;min-width:0; + overflow-x:auto;overflow-y:hidden; + touch-action:pan-x;overscroll-behavior-x:contain; + -webkit-overflow-scrolling:touch; + scrollbar-width:thin; + } + .app .command-bar .more-tools{ + order:-1;margin-left:0;left:0;position:sticky;z-index:2; + } + .app .command-bar .more-tools-panel{ + position:fixed;left:8px;right:8px;top:64px;width:auto; + max-height:calc(100dvh - 76px);overflow:auto;z-index:60; + } + .app .console-pane{min-width:0} + .app .tracks-viewport{min-width:0} +} \ No newline at end of file diff --git a/src/ApprovedConsoleNativeTransportV6.h b/src/ApprovedConsoleNativeTransportV6.h index 843d263bd..c964e3e19 100644 --- a/src/ApprovedConsoleNativeTransportV6.h +++ b/src/ApprovedConsoleNativeTransportV6.h @@ -117,6 +117,19 @@ inline juce::var snapshot (const juce::var& live, primaryOutputArmed, active != nullptr ? active->getActiveInputChannels().countNumberOfSetBits() : 0, active != nullptr ? active->getActiveOutputChannels().countNumberOfSetBits() : 0)); + // Optional output-copy readback comes only from the native WASAPI + // consumer. Never equate an armed virtual endpoint with audible speakers + // or OBS/TikTok receiving audio. + auto secondary=std::make_unique(); + secondary->setProperty("ready",live.getProperty("secondaryOutputReady",false)); + secondary->setProperty("armed",live.getProperty("secondaryOutputArmed",false)); + secondary->setProperty("fault",live.getProperty("secondaryOutputFault",false)); + secondary->setProperty("endpoint",live.getProperty("secondaryOutputName","")); + secondary->setProperty("rate",live.getProperty("secondaryOutputRate",0.0)); + secondary->setProperty("latencyMs",live.getProperty("secondaryOutputBridgeMs",0.0)); + secondary->setProperty("underflowFrames",live.getProperty("secondaryOutputUnderflow",0.0)); + secondary->setProperty("overflowFrames",live.getProperty("secondaryOutputOverflow",0.0)); + root->setProperty("secondaryOutput",juce::var(secondary.release())); return juce::var (root.release()); } diff --git a/src/ApprovedNativeV8Projection.h b/src/ApprovedNativeV8Projection.h index ab95387fd..b5f4b4cc5 100644 --- a/src/ApprovedNativeV8Projection.h +++ b/src/ApprovedNativeV8Projection.h @@ -82,6 +82,11 @@ inline bool projectApprovedNativeV8(juce::var& snapshot,const juce::var& bus) { fx.add(juce::var(insert.release())); } ch->setProperty("inserts",juce::var(fx)); + const auto rackBypassed=row.getProperty("fxRackBypassed",{}); + if(!rackBypassed.isVoid()) { + if(!rackBypassed.isBool())return false; + ch->setProperty("fxRackBypassed",rackBypassed); + } ch->setProperty("sends",juce::var(juce::Array{})); if(role!="INPUT"){ auto dst=std::make_unique(); diff --git a/src/ConsoleLiveBridgeV6.h b/src/ConsoleLiveBridgeV6.h index a30991611..8db86ac42 100644 --- a/src/ConsoleLiveBridgeV6.h +++ b/src/ConsoleLiveBridgeV6.h @@ -150,6 +150,8 @@ class LiveConsoleBridgeV6 final { if(peaksL.isArray())object->setProperty("channelPeaksL",peaksL); if(peaksR.isArray())object->setProperty("channelPeaksR",peaksR); if(inserts.isArray())object->setProperty("fxInstances",inserts); + const auto rackPower=route.getProperty("fxRackBypassed",juce::var()); + if(rackPower.isArray())object->setProperty("fxRackBypassed",rackPower); // The prepared/unpatched native M4 graph is a real silent route. // It allows direct IN gesture to activate the FIRST source. // This does not set productionCallbackLive or fake PCM. diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index a864556e1..57451f9dc 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -91,6 +91,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } std::array slots {}; std::array, maxFx> bypassFlags {}; + std::atomic rackBypassed{false}; // does not overwrite per-slot flags // Owned and advanced exclusively by the realtime render callback. // Physical-slot identity survives an atomic logical reorder (PR #102). std::array bypassEnvelope {}; @@ -276,6 +277,13 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return "MUTE hardware OUTPUT, APPLY real input routing and use verified DIRECT before secondary device setup"; auto* device=deviceManager_.getCurrentAudioDevice(); if(!device)return "Direct capture/output hardware is not available"; + // STREAM is an additional render-only copy. A capture endpoint + // paired with its own VB-Cable playback can feed itself indefinitely. + // Reject that known loop independently of WebView safety guards. + juce::AudioDeviceManager::AudioDeviceSetup directSetup; + deviceManager_.getAudioDeviceSetup(directSetup); + if(knownVirtualCableFeedbackPair(directSetup.inputDeviceName,selected)) + return "STREAM OFF: same VB-Cable input/output feedback loop"; return secondaryOutput_.open(selected,device->getName(), device->getCurrentSampleRate(), device->getCurrentBufferSizeSamples()); @@ -1248,6 +1256,16 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback !=armix::diagnostics::Route::normal)return false; return dryRoutingLab_.setFxBypass(lane,slot,epoch,revision,instanceId,bypass); } + bool setDryRoutingLabFxRackBypass(int lane,std::uint64_t epoch, + std::uint64_t revision,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + if(!dryRoutingLab_.setFxRackBypass(lane,epoch,revision,bypass))return false; + if(lane==0 && graphOwned_) + graphOwned_->rackBypassed.store(bypass,std::memory_order_release); + return true; + } armix::mixer::LiveChannelFxGraph::InstanceLease leaseRoutedFxForEditor( int lane,int slot,std::uint64_t epoch,std::uint64_t revision, const juce::String& instanceId) const noexcept { @@ -1352,6 +1370,18 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return dryRoutingLab_.bypassNativeInsert(epoch,revision,id,slot, token,bypass); } + bool bypassNativeFxRack(std::uint64_t epoch,std::uint64_t revision, + armix::mixer::ChannelId id,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + if(!dryRoutingLab_.bypassNativeRack(epoch,revision,id,bypass))return false; + // The original CH1 VST3 instance can be external-leased into the + // native ChannelId publisher. Its own crossfade gate must agree. + if(graphOwned_ && dryRoutingLab_.nativeChannelIsOriginalCh1(id)) + graphOwned_->rackBypassed.store(bypass,std::memory_order_release); + return true; + } armix::mixer::LiveChannelFxGraph::InstanceLease leaseNativeVst3Editor( std::uint64_t epoch,std::uint64_t revision, armix::mixer::ChannelId id,std::size_t slot, @@ -1954,7 +1984,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback auto& slot=graph.slots[physical]; if(!slot.processor)continue; auto& bypass=graph.bypassEnvelope[physical]; - bypass.request(graph.bypassFlags[physical].load(std::memory_order_acquire)); + bypass.request(graph.rackBypassed.load(std::memory_order_acquire) || + graph.bypassFlags[physical].load(std::memory_order_acquire)); const bool blend=bypass.transitioning(); if(blend) { diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 82f5ea88b..d1fe16ebb 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -946,6 +946,16 @@ class LiveDryRoutingLab final { }); } + // Master rack gate is a single RT-visible atomic per lane; never overwrite + // stored individual insert bypass flags. Safe under current epoch/revision. + bool setFxRackBypass(int lane,std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,bool bypass) noexcept { + if(lane<0||lane>=fxSlots||!hasExplicitRoute()|| + expectedEpoch!=epoch()||expectedRevision!=revision())return false; + return publisher_.updateActiveControl(expectedEpoch,expectedRevision, + [&](FxGraph& fx) noexcept {return fx.setRackBypass(lane,bypass);}); + } + // Quiescent message-thread identity lease for the vendor's native GUI. // Shared lifetime is independent of route reorder, but not authority: // an editor request MUST match the current accepted route. @@ -1197,6 +1207,16 @@ class LiveDryRoutingLab final { return nativeAccepted_.setFxBypass(nativePublisher_,epochAtEdit, pcmRevision,target,slot,token,bypass); } + bool nativeChannelIsOriginalCh1(armix::mixer::ChannelId target) const noexcept { + return nativeAccepted_.fxOwners && + nativeAccepted_.fxOwners->externalChannel()==target && + target==nativeAccepted_.graph.ids.inputs[0]; + } + bool bypassNativeRack(std::uint64_t epochAtEdit,std::uint64_t pcmRevision, + armix::mixer::ChannelId target,bool bypass) noexcept { + return nativeAccepted_.setFxRackBypass(nativePublisher_,epochAtEdit, + pcmRevision,target,bypass); + } armix::mixer::DynamicChannelFxLeaseBank::Lease leaseNativeInsertEditor( std::uint64_t epochAtEdit,std::uint64_t pcmRevision, armix::mixer::ChannelId target,std::size_t slot, @@ -1720,6 +1740,8 @@ class LiveDryRoutingLab final { liveInserts.add(juce::var(item.release())); } row->setProperty("inserts",juce::var(liveInserts)); + row->setProperty("fxRackBypassed", + nativeAccepted_.fxOwners->rackBypassed(ch.id)); if(pcmMeterValid && meterIndexsetProperty("peakL",static_cast( nativeMeterPeaksL_[meterIndex].load(std::memory_order_relaxed))); @@ -2169,6 +2191,10 @@ class LiveDryRoutingLab final { liveFxInstances.add(juce::var(slots)); } out->setProperty("fxInstances",juce::var(liveFxInstances)); + juce::Array rackFlags; + for(int lane=0;lanerackBypassed(lane):false); + out->setProperty("fxRackBypassed",juce::var(rackFlags)); juce::Array controls,fxNames; for(int i=0;i(); + ack->setProperty("requestId",args.getProperty("requestId",{})); + ack->setProperty("ok",false); + ack->setProperty("error",reason); + browser_.emitEventIfBrowserIsVisible( + "arMixNativeFxPowerAck",juce::var(ack.release())); + } return emitNotice(reason,true); } @@ -1702,6 +1713,65 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(!ok)emitNotice("Live AUX send rejected; refresh accepted routing.",true); return; } + // Accepted ChannelId FX power. A rack master is an additive gate, + // not a rewrite of the eight saved individual bypass preferences. + // Both gestures are fenced to the actual device epoch + PCM revision + // and reply with an ACK; the WebView re-reads the producer snapshot. + if(action=="routingNativeFxRackBypass" || + action=="routingNativeFxInsertBypass") { + const auto request=args.getProperty("requestId",{}).toString(); + const auto rawId=args.getProperty("channelId",{}); + const auto rawEpoch=args.getProperty("deviceEpoch",{}); + const auto rawRevision=args.getProperty("revision",{}); + const auto parse=[](const juce::var& wire,std::uint64_t& out) -> bool { + if(!wire.isString())return false; + const auto text=wire.toString().toStdString(); + if(text.empty()||text.size()>20|| + text[0]=='0'||text.find_first_not_of("0123456789")!=std::string::npos) + return false; + try { + const auto decoded=std::stoull(text); + if(!decoded||std::to_string(decoded)!=text)return false; + out=decoded;return true; + } catch(...) {return false;} + }; + std::uint64_t channel=0,ep=0,rev=0; + const bool valid=request.isNotEmpty()&&request.length()<=128 && + parse(rawId,channel)&&parse(rawEpoch,ep)&& + parse(rawRevision,rev)&&value.isBool() && + !studioBackupBusy_&&!nativeShowBusy_&& + !engine_.independentClockActive(); + bool applied=false; + if(valid && !acceptedControlRequests_.contains(request)) { + acceptedControlRequests_.add(request); + if(acceptedControlRequests_.size()>512) + acceptedControlRequests_.remove(0); + const armix::mixer::ChannelId id{channel}; + if(action=="routingNativeFxRackBypass") + applied=engine_.bypassNativeFxRack(ep,rev,id,static_cast(value)); + else { + const auto token=args.getProperty("insertId",{}).toString(); + applied=slot>=0&&slot(slot),token,static_cast(value)); + } + } + auto ack=std::make_unique(); + ack->setProperty("requestId",request); + ack->setProperty("ok",applied); + ack->setProperty("channelId",rawId); + ack->setProperty("bypassed",value); + ack->setProperty("error",applied?juce::String(): + "Native FX power rejected: stale device/revision, Show busy or instance mismatch"); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixNativeFxPowerAck",juce::var(ack.release())); + if(applied)diagnostics_.record("NATIVE_FX_POWER", + rawId.toString()+(action=="routingNativeFxRackBypass"?" rack":" insert")+ + (static_cast(value)?" BYPASS":" ENABLE")); + return; + } + // G5C native per-instance BYPASS never recompiles the graph and // does not require muting the output. All identity gates must agree. if (action == "routingFxBypass") { @@ -2059,8 +2129,18 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(action=="secondaryOutputConnect" || action=="secondaryOutputArm" || action=="secondaryOutputStop") { juce::String error; - if(studioBackupBusy_ || nativeShowBusy_) - error="Complete active Show/backup operation before editing secondary output"; + const auto requestId=args.getProperty("requestId",juce::var()); + const auto expectedEpoch=args.getProperty("expectedDeviceEpoch",juce::var()); + const auto actualEpoch=static_cast(engine_.dryRoutingLabEpoch()); + const bool epochValid=(expectedEpoch.isInt()||expectedEpoch.isInt64()|| + expectedEpoch.isDouble()) && + static_cast(expectedEpoch)==actualEpoch && actualEpoch>0; + // Explicit STOP is the safety escape hatch, even after a hotplug. + // CONNECT/ARM must belong to the exact current DIRECT device. + if(action!="secondaryOutputStop" && !epochValid) + error="STREAM: device changed; reselect an output"; + else if(action!="secondaryOutputStop" && (studioBackupBusy_ || nativeShowBusy_)) + error="Complete active Show/backup before connecting STREAM"; else if(action=="secondaryOutputConnect") { if(!value.isString() || value.toString().length()>240) error="Select a real named Windows playback endpoint"; @@ -2070,9 +2150,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr else error=engine_.armSecondaryOutput(bool(value)); } else engine_.disconnectSecondaryOutput(); auto ack=std::make_unique(); + ack->setProperty("requestId",requestId.isString()?requestId:juce::var("")); + ack->setProperty("deviceEpoch",juce::String(actualEpoch)); ack->setProperty("ok",error.isEmpty()); ack->setProperty("error",error); const auto latest=engine_.status(); + ack->setProperty("fault",latest.getProperty("secondaryOutputFault",false)); ack->setProperty("ready",latest.getProperty("secondaryOutputReady",false)); ack->setProperty("armed",latest.getProperty("secondaryOutputArmed",false)); ack->setProperty("endpoint",latest.getProperty("secondaryOutputName","")); diff --git a/tests/approved_css_stage_c_compiler_test.py b/tests/approved_css_stage_c_compiler_test.py index 5fb9039f2..40e21905c 100644 --- a/tests/approved_css_stage_c_compiler_test.py +++ b/tests/approved_css_stage_c_compiler_test.py @@ -153,6 +153,21 @@ def test_stage_d_single_cssom_preserves_owner_order_and_relative_assets(self): with self.assertRaisesRegex(ValueError,"@import"): css.compile_runtime_bundle([("a.css",'@import url("other.css");.x{opacity:1}')]) + def test_stage_d_consumes_complete_link_tags_no_stray_gt_in_mobile_body(self): + # Regression: previous LINK matched closing quote but not '>'. After + # removing 18 tags the browser displayed '> > > ...' before ArSonMix. + owners = "".join( + f'' + for i in range(18) + ) + document = "" + owners + "
ArSonMix
" + rebuilt = css.link_runtime_bundle(document, "0123456789abcdef") + expected = ('' + '
ArSonMix
') + self.assertEqual(rebuilt, expected, "No orphan > text nodes from removed links") + self.assertEqual(len(list(css.LINK.finditer(rebuilt))), 1) + def test_stage_d_retains_fallbacks_for_older_webview2_and_missing_vars(self): original='.control{color:#fff;color:var(--preferred-color)}' optimized,stats=css.optimize_css([("a.css",original)]) diff --git a/tests/approved_fx_rack_master_power_smoke.py b/tests/approved_fx_rack_master_power_smoke.py new file mode 100644 index 000000000..25eb5dd9e --- /dev/null +++ b/tests/approved_fx_rack_master_power_smoke.py @@ -0,0 +1,89 @@ +"""P0 FX rack: header bypass overrides effective power, never saved slots. + +Chromium exercises ONE actual built /preview/ GUI (also used by native JUCE). +Public Pages only demonstrates the control state; real DSP is checked in +native engine contracts/Windows CTest and physical hardware FAT separately. +""" +from pathlib import Path +from playwright.sync_api import sync_playwright + +PAGE=Path(__file__).resolve().parents[1]/"dist-pages/preview/index.html" + + +def snapshot(page, channel=1): + root=page.locator(f'#tracks .strip[data-id="{channel}"] .fx-section') + return root.evaluate("""el=>({ + rack:el.dataset.fxChainEnabled, + header:el.querySelector('[data-action="fxOn"]').getAttribute('aria-pressed'), + slots:[...el.querySelectorAll('.fxslot-row:not(.is-empty)')].map(row=>({ + id:row.dataset.insertId, + individual:row.dataset.fxSlotEnabled, + effective:row.dataset.fxEffective, + power:row.querySelector('[data-action="slotPower"]') + ?.getAttribute('aria-pressed'), + bypassed:row.classList.contains('is-bypassed') + })) + })""") + + +def main(): + assert PAGE.is_file(), "build official /preview/ first" + with sync_playwright() as pw: + browser=pw.chromium.launch(headless=True) + try: + for width,height in [(390,844),(1366,768),(1680,900)]: + page=browser.new_page(viewport={"width":width,"height":height}) + errors=[] + page.on("pageerror",lambda e:errors.append(str(e))) + page.goto(PAGE.as_uri()) + page.locator("#tracks .strip[data-id='1']").wait_for() + root=page.locator('#tracks .strip[data-id="1"]') + initial=snapshot(page) + assert len(initial["slots"])==1 and initial["slots"][0]["power"]=="true",initial + # Load the second effect using the actual UI picker. + root.locator('.fx-pick.empty').click() + page.locator('#fastResults [data-fast-id]').first.click() + both=snapshot(page) + assert len(both["slots"])==2 and all( + x["power"]=="true" for x in both["slots"]),both + # Individual OFF is a stored preference, never overwritten. + root.locator('[data-action="slotPower"][data-slot="0"]').click() + individual=snapshot(page) + assert individual["slots"][0]["individual"]=="false",individual + assert individual["slots"][1]["individual"]=="true",individual + # On phones the official console banks one channel at a + # time; inspect CH2 via its real bank selector, not a hidden DOM. + if width < 500: + page.locator("#bankSelect").select_option("1") + other=snapshot(page,2) + if width < 500: + page.locator("#bankSelect").select_option("0") + root.locator('[data-action="fxOn"]').click() + off=snapshot(page) + assert off["header"]==off["rack"]=="false",off + assert all(row["power"]=="false" and + row["effective"]=="false" and row["bypassed"] + for row in off["slots"]),off + assert [r["individual"] for r in off["slots"]]==["false","true"],off + assert [r["id"] for r in off["slots"]]==[r["id"] for r in individual["slots"]],off + if width < 500: + page.locator("#bankSelect").select_option("1") + assert snapshot(page,2)==other,"Rack power leaked into other channel" + if width < 500: + page.locator("#bankSelect").select_option("0") + root.locator('[data-action="fxOn"]').click() + restored=snapshot(page) + assert restored["header"]==restored["rack"]=="true",restored + assert [r["power"] for r in restored["slots"]]==["false","true"],restored + assert [r["effective"] for r in restored["slots"]]==["false","true"],restored + assert [r["individual"] for r in restored["slots"]]==["false","true"],restored + assert [r["id"] for r in restored["slots"]]==[r["id"] for r in individual["slots"]],restored + assert not errors,errors + print("PASS FX rack master power + saved individual state",width,height) + page.close() + finally: + browser.close() + + +if __name__=="__main__": + main() diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index e20952262..ad9119177 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -243,6 +243,90 @@ static void controlIntentTranslationCases(const juce::var& canonical, } +// P1 WIRE gateway regression: all ChannelId/EdgeId conversion is validated +// on the CONTROL thread. A test probe is not a hardware PCM producer. +struct NativeWireProbe { + std::uint64_t epoch=0,pcmRevision=0,rosterRevision=0; + std::vector applied; + struct Result { bool accepted=false; juce::String error; }; + Result applyNativeWireTransaction(std::uint64_t ep,std::uint64_t rev, + std::uint64_t roster,std::span edits) { + epoch=ep;pcmRevision=rev;rosterRevision=roster; + applied.assign(edits.begin(),edits.end()); + return {true,{}}; + } +}; +static void approvedWireTranslationRegression(const juce::var& canonical, + const juce::var& producer) { + auto accepted=juce::JSON::parse(juce::JSON::toString(canonical,false)); + auto bus=juce::JSON::parse(juce::JSON::toString(producer,false)); + juce::Array publicOps,nativeOps; + publicOps.add("APPLY_WIRE_TRANSACTION"); + nativeOps.add("NATIVE_APPLY_WIRE_TRANSACTION"); + accepted.getProperty("graph",{}).getProperty("capabilities",{}) + .getDynamicObject()->setProperty("supportedOps",juce::var(publicOps)); + bus.getDynamicObject()->setProperty("supportedOps",juce::var(nativeOps)); + const juce::String id="9007199254740993"; + const juce::String edge="9223372036854775808"; + auto request=std::make_unique(); + request->setProperty("requestId","p1-wire-control-test"); + request->setProperty("operation","APPLY_WIRE_TRANSACTION"); + request->setProperty("targetChannelId",id); + request->setProperty("deviceEpoch","91"); + request->setProperty("baseGraphRevision","25"); + request->setProperty("baseRosterRevision","9"); + auto one=std::make_unique(); + one->setProperty("op","REMOVE"); + one->setProperty("from",id); + one->setProperty("edgeId",edge); + juce::Array changes;changes.add(juce::var(one.release())); + auto payload=std::make_unique(); + payload->setProperty("changes",juce::var(changes)); + request->setProperty("payload",juce::var(payload.release())); + const auto original=juce::var(request.release()); + const auto translated=translateApprovedNativeControl(original,accepted,bus); + assert(translated.ok()); + assert(translated.translated.getProperty("operation","").toString() + =="NATIVE_APPLY_WIRE_TRANSACTION"); + NativeWireProbe native; + assert(executeApprovedNativeControl(native,translated.translated)); + assert(native.epoch==91&&native.pcmRevision==25&&native.rosterRevision==9); + assert(native.applied.size()==1); + assert(native.applied[0].kind==armix::mixer::WireChange::Kind::remove); + assert(native.applied[0].from.value==9007199254740993ULL); + assert(native.applied[0].edgeId==9223372036854775808ULL); + + auto fail=[&](juce::var intent,juce::var acceptedState,juce::var nativeState){ + const auto before=juce::JSON::toString(nativeState,false); + const auto result=translateApprovedNativeControl(intent,acceptedState,nativeState); + assert(!result.ok());assert(!result.translated.isObject()); + assert(juce::JSON::toString(nativeState,false)==before); + return result.error; + }; + auto forged=juce::JSON::parse(juce::JSON::toString(original,false)); + forged.getProperty("payload",{}).getProperty("changes",{})[0] + .getDynamicObject()->setProperty("edgeId","9223372036854775807"); + assert(fail(forged,accepted,bus)=="WIRE_STALE_EDGE"); + auto wrongSource=juce::JSON::parse(juce::JSON::toString(original,false)); + wrongSource.getProperty("payload",{}).getProperty("changes",{})[0] + .getDynamicObject()->setProperty("from","18446744073709551615"); + assert(fail(wrongSource,accepted,bus)=="WIRE_SOURCE_OR_OPERATION_INVALID"); + auto stale=juce::JSON::parse(juce::JSON::toString(original,false)); + stale.getDynamicObject()->setProperty("baseGraphRevision","24"); + assert(fail(stale,accepted,bus)=="STALE_NATIVE_CONTROL_REVISION"); + auto noNative=juce::JSON::parse(juce::JSON::toString(bus,false)); + noNative.getDynamicObject()->setProperty("supportedOps", + juce::var(juce::Array{})); + assert(fail(original,accepted,noNative)=="NATIVE_WIRE_NOT_ADMITTED"); + auto invalidTap=juce::JSON::parse(juce::JSON::toString(original,false)); + auto edit=invalidTap.getProperty("payload",{}).getProperty("changes",{})[0]; + edit.getDynamicObject()->setProperty("op","CONNECT"); + edit.getDynamicObject()->setProperty("to","18446744073709551615"); + edit.getDynamicObject()->setProperty("tap","PRE_FADER"); + edit.getDynamicObject()->setProperty("gainLinear",1.0); + assert(fail(invalidTap,accepted,bus)=="WIRE_UNSUPPORTED_TAP_OR_GAIN"); +} + static void installedCallbackAdmissionRegression(const juce::var& rawBus) { // This fixture is ONLY accepted native readback; not a hardware device. // It proves Main.cpp cannot publish a fake live graph from G0/M4 JSON. @@ -519,6 +603,7 @@ int main() { assert(!static_cast(snap.getProperty("productionCallbackLive",false))); controlIntentTranslationCases(snap,bus); + approvedWireTranslationRegression(snap,bus); installedCallbackAdmissionRegression(bus); firstSoundRouteAdmissionRegression(); firstSoundMeasuredSignalEvidenceRegression(); diff --git a/tests/approved_preview_mobile_navigation_smoke.py b/tests/approved_preview_mobile_navigation_smoke.py new file mode 100644 index 000000000..58367b6e1 --- /dev/null +++ b/tests/approved_preview_mobile_navigation_smoke.py @@ -0,0 +1,153 @@ +"""P0 mobile /preview/ regression: toolbar/nav must not render stray > glyphs. + +Tests the actual official assembled Pages DOM and PNG-key skin in real Chromium +with mobile viewport + touch, not a second HTML, temporary CSS patch or mock UI. +""" +import asyncio +import re +from pathlib import Path +from playwright.async_api import async_playwright + +ROOT = Path(__file__).resolve().parents[1] +PAGE = ROOT / "dist-pages/preview/index.html" + + +async def verify_phone(browser, width: int, height: int): + context = await browser.new_context( + viewport={"width": width, "height": height}, + is_mobile=True, + has_touch=True, + device_scale_factor=2, + ) + page = await context.new_page() + errors = [] + page.on("pageerror", lambda e: errors.append(str(e))) + try: + await page.goto(PAGE.as_uri()) + await page.wait_for_selector("#tracks .strip[data-id='1']") + await page.evaluate("document.fonts.ready") + info = await page.evaluate("""() => { + const bar = document.querySelector(".command-bar"); + const more = document.querySelector("#moreTools summary"); + const root = document.documentElement; + const mixer = document.querySelector(".tracks-viewport"); + const points = [...document.querySelectorAll( + ".window-title *, .command-bar *, .section-rail *")]; + const glyphs = []; + for (const el of points) { + for (const pseudo of ["::before", "::after"]) { + const content = getComputedStyle(el, pseudo).content; + if (content && /(?:>{3,}|[›❯▸]{7,})/.test(content)) + glyphs.push({element:el.tagName, className:el.className, + pseudo, content}); + } + } + const a = bar.getBoundingClientRect(); + const m = more.getBoundingClientRect(); + return { + viewport: innerWidth, pageWidth:root.scrollWidth, + appWidth: document.querySelector(".app").getBoundingClientRect().width, + toolbarWidth: a.width, toolbarLeft:a.left, + toolbarClient: bar.clientWidth, toolbarScroll: bar.scrollWidth, + toolbarOverflow: getComputedStyle(bar).overflowX, + moreLeft: m.left, moreRight:m.right, + moreText: more.textContent.trim(), + mixerClient:mixer.clientWidth,mixerScroll:mixer.scrollWidth, + channelBanks:document.querySelectorAll("#bankSelect option").length, + visualText:document.body.innerText, + literalMarker:document.body.innerText.includes(">>>>>>>"), + pseudoMarkers:glyphs, + stylesheets:[...document.querySelectorAll('link[rel="stylesheet"]')] + .map(l=>l.href) + }; + }""") + assert info["viewport"] == width, (width, info) + assert info["appWidth"] <= width + 1, ("desktop min-width leaks on phone", info) + assert info["toolbarWidth"] <= width + 1, ("toolbar is outside viewport", info) + assert info["pageWidth"] <= width + 2, ("unscrollable full-page overflow", info) + assert info["toolbarOverflow"] == "auto", ("toolbar cannot swipe", info) + assert info["toolbarScroll"] > info["toolbarClient"] + 90, info + assert 0 <= info["moreLeft"] < info["moreRight"] <= width, info + # At phone widths the approved mixer shows one channel PER BANK + # instead of a horizontally overflowing ten-channel strip. Bank + # selector and Next remain the official navigation authority. + assert info["mixerClient"] > 75 and info["channelBanks"] > 1, info + assert not re.match(r"^(?:>\s*){3,}", info["visualText"]), ( + "orphaned CSS-link closing > rendered above title", info["visualText"][:90]) + assert info["literalMarker"] is False and not info["pseudoMarkers"], ( + "stray mobile >>>>>>> chevrons/conflict markers", info) + assert len(info["stylesheets"]) == 1, ("extra CSS layers", info) + assert "arsonmix-approved-runtime.css?sha=" in info["stylesheets"][0], info + + # Approved original PNG hardware MUTE is unchanged and clickable. + mute = page.locator("#tracks .strip[data-id='1'] .mx-hw-key[data-hw-kind='mute']") + await mute.click() + assert await mute.get_attribute("aria-pressed") == "true" + await page.screenshot(path=f"pages-mobile-viewport-{width}.png") + # Bank navigation is genuine, not a fake replacement mobile mixer. + assert await page.locator(".strip[data-id='1']").count() == 1 + await page.locator("#bankSelect").select_option("1") + await page.wait_for_selector("#tracks .strip[data-id='2']") + assert await page.locator(".strip[data-id='1']").count() == 0 + await page.locator("#bankSelect").select_option("0") + await page.wait_for_selector("#tracks .strip[data-id='1']") + + # Toolbar is genuinely swipeable; More remains reachable while scrolling. + await page.locator(".command-bar").evaluate("(bar)=>{bar.scrollLeft=bar.scrollWidth;}") + scroll = await page.locator(".command-bar").evaluate("(bar)=>bar.scrollLeft") + assert scroll > 90, ("toolbar overflow locked against touch scrolling", scroll) + await page.locator("#moreTools summary").click() + panel = page.locator("#moreTools .more-tools-panel") + await panel.wait_for(state="visible") + position = await panel.evaluate("""el => { + const rect=el.getBoundingClientRect(); + return {position:getComputedStyle(el).position, + left:rect.left,right:rect.right,top:rect.top, + bottom:rect.bottom,width:rect.width,height:rect.height}; + }""") + assert position["position"] == "fixed", position + assert 0 <= position["left"] <= position["right"] <= width, position + assert position["top"] >= 40 and position["bottom"] <= height + 1, position + assert await panel.locator("#addTrack").is_visible() + await page.screenshot(path=f"pages-mobile-toolbar-more-{width}.png") + await page.locator("#moreTools summary").click() + assert not errors, errors + print(f"PASS {width}x{height} mobile: one CSS, no orphan > marker, " + f"swipe toolbar + real channel banks, fixed More popup, PNG MUTE") + finally: + await context.close() + + +async def verify_desktop(browser): + page = await browser.new_page(viewport={"width": 1366, "height": 768}) + try: + await page.goto(PAGE.as_uri()) + await page.wait_for_selector("#tracks .strip[data-id='1']") + result = await page.evaluate("""() => ({ + rootMin:getComputedStyle(document.body).minWidth, + toolbarOverflow:getComputedStyle(document.querySelector('.command-bar')).overflowX, + morePosition:getComputedStyle(document.querySelector('.more-tools-panel')).position, + sheets:document.querySelectorAll('link[rel="stylesheet"]').length + })""") + assert result["toolbarOverflow"] == "visible", result + assert result["morePosition"] == "absolute", result + assert result["sheets"] == 1, result + print("PASS desktop unaffected by mobile-specific toolbar navigation",result) + finally: + await page.close() + + +async def main(): + assert PAGE.is_file(), "Build the official /preview/ first" + async with async_playwright() as p: + browser = await p.chromium.launch(headless=True) + try: + for size in [(360, 780), (390, 844), (430, 932)]: + await verify_phone(browser, *size) + await verify_desktop(browser) + finally: + await browser.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/tests/live_channel_fx_graph_test.cpp b/tests/live_channel_fx_graph_test.cpp index 515c7481c..475d820a1 100644 --- a/tests/live_channel_fx_graph_test.cpp +++ b/tests/live_channel_fx_graph_test.cpp @@ -178,7 +178,18 @@ static void verifyUniversalChannelIdFxLeaseAndLivePcm() { auto second=newFx(1.25f,"ch11-second-vst3"); assert(Bank::appendOwned(epoch,3,bank,ch11,ProcessingFormat::mono, second,expanded)==Bank::Fault::none); + // Rack OFF applies to the new plugin too; old per-plugin OFF remains + // untouched and native append carries the same authoritative override. + assert(bank.setRackBypass(epoch,2,ch11,true)); + assert(bank.rackBypassed(ch11)); assert(expanded.insertCount(ch11)==2); + // expanded was already created before the OFF gesture. Its revision + // holds the same shared rack gate, so it observes the control live. + assert(expanded.rackBypassed(ch11)); + assert(!expanded.setRackBypass(epoch,2,ch11,false)); // stale version + assert(expanded.setRackBypass(epoch,3,ch11,false)); + assert(!bank.rackBypassed(ch11)); + assert(!expanded.rackBypassed(ch11)); assert(expanded.insertCount(ch1)==bank.insertCount(ch1)); assert((*expanded.ownerForControl(ch11,0))->instanceId== (*bank.ownerForControl(ch11,0))->instanceId); @@ -2246,6 +2257,33 @@ int main(int argc,char** argv) { assert(heapCalls.load(std::memory_order_relaxed)==beforeNextProcess); assert(left[0]>.3f); } + // FX RACK POWER: one atomic master overrides effective processing, + // without destroying the ON/OFF preferences of individual inserts. + { + auto graph=makeGraph(2.f,3.f); + const auto token=graph->insertInstanceId(0); + assert(!graph->rackBypassed(0)); + assert(graph->setInsertBypass(0,0,token,true)); // individual OFF + assert(graph->insertBypassed(0,0)); + assert(graph->setRackBypass(0,true)); // master OFF + assert(graph->rackBypassed(0)&&graph->insertBypassed(0,0)); + assert(graph->setRackBypass(0,false)); // master ON + assert(!graph->rackBypassed(0)); + assert(graph->insertBypassed(0,0)); // stays OFF + assert(graph->setInsertBypass(0,0,token,false)); + assert(graph->setRackBypass(0,true)); + assert(graph->setRackBypass(0,false)); + assert(!graph->insertBypassed(0,0)); // returns to ON + assert(!graph->setRackBypass(-1,true)); + assert(!graph->setRackBypass(LiveChannelFxGraph::fxSlots,true)); + auto moved=makeGraph(1.f,1.f,false); + assert(graph->setRackBypass(0,true)); + assert(moved->reuse(0,*graph,"vst3-ch1-id")); + assert(moved->rackBypassed(0)); // graph retirement retains gate + assert(moved->insertBypassed(0,0)==graph->insertBypassed(0,0)); + assert(moved->setRackBypass(0,false)); + assert(!moved->insertBypassed(0,0)); // saved ON restored + } // Run M5 AFTER the legacy suite: older M4 tests use absolute global // GainFx::living/released counters as their own lifetime oracle. Running // M5 before them changes those historical baseline counts, not DSP. diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index 6edcd12f1..b33a201fd 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -62,7 +62,10 @@ test('bypass is sample-smoothed by one original CH1 DSP owner for M4 and native 'native and M4 must share the original CH1 sample-accurate DSP owner'); const originalDSP=e.slice(start,legacy); const adapters=e.slice(legacy,end); - assert.match(originalDSP,/bypass\.request\(graph\.bypassFlags/); + assert.match(originalDSP,/bypass\.request\(graph\.rackBypassed\.load/); + assert.match(originalDSP,/graph\.bypassFlags\[physical\]\.load/); + assert.match(originalDSP,/\|\|/, "rack override must OR with individual insert bypass"); + assert.match(originalDSP,/slot\.processor->processBlock\(buffer,midi\)/); assert.match(originalDSP,/bypass\.transitioning\(\)/); assert.match(originalDSP,/graph\.dryScratch\.getWritePointer\(0\)/); diff --git a/tests/p1_stream_wire_fx_contract.test.cjs b/tests/p1_stream_wire_fx_contract.test.cjs new file mode 100644 index 000000000..b11c74d78 --- /dev/null +++ b/tests/p1_stream_wire_fx_contract.test.cjs @@ -0,0 +1,32 @@ +const {test} = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'), path = require('node:path'); +const read = p => fs.readFileSync(path.join(__dirname,'..',p),'utf8'); +test('P1 stream copies native post-FX MAIN through selected independent WASAPI consumer',()=>{ + const ui=read('web/approved-native-bridge.js'); + const host=read('src/Main.cpp'), engine=read('src/LiveAudioEngine.h'); + const device=read('engine/device/LiveSecondaryOutputDevice.h'); + assert.match(ui,/data-stream-panel/); + for(const s of ['connect','live','stop'])assert.ok(ui.includes('data-stream-action="'+s+'"')); + assert.match(ui,/arMixSecondaryOutputAck/); + assert.match(host,/expectedDeviceEpoch/); + assert.match(host,/ack->setProperty\("requestId",requestId/); + assert.match(engine,/STREAM OFF: same VB-Cable input\/output feedback loop/); + assert.match(device,/render-ONLY WASAPI clock consumer/); +}); +test('P1 native FX master gate preserves slots and awaits actual readback',()=>{ + const ui=read('web/approved-native-bridge.js'); + const fx=read('engine/core/LiveChannelFxGraph.h'); + assert.match(ui,/arMixNativeFxPowerAck/); + assert.match(ui,/pendingNativeFxPower\?\.acked/); + assert.match(ui,/routingNativeFxRackBypass/); + assert.match(fx,/rackBypassed \|\| bypassRequested/); +}); +test('P1 WIRE gateway validates EdgeId and checks physical/stream output safety',()=>{ + const ui=read('web/approved-native-bridge.js'); + const translator=read('integration/ApprovedNativeControlIntent.h'); + assert.match(ui,/WIRE requires MONITOR OFF and STREAM stopped/); + assert.match(translator,/WIRE_STALE_EDGE/); + assert.match(translator,/NATIVE_APPLY_WIRE_TRANSACTION/); + assert.match(translator,/engine\.applyNativeWireTransaction/); +}); diff --git a/tests/single_preview_publication_contract_test.py b/tests/single_preview_publication_contract_test.py index ea2397a95..93d23b9b7 100644 --- a/tests/single_preview_publication_contract_test.py +++ b/tests/single_preview_publication_contract_test.py @@ -3,6 +3,7 @@ import json, re, sys, hashlib sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts')) from compile_approved_css import LINK, optimize_css, compile_runtime_bundle, link_runtime_bundle, RUNTIME_CSS +from approved_fx_rack_power import apply_authoritative_fx_power ROOT=Path(__file__).resolve().parents[1] DST=Path(sys.argv[1]).resolve() if len(sys.argv)>1 else ROOT/'dist-pages' gui=DST/'preview' @@ -36,6 +37,7 @@ def require(ok,why): require((gui/'assets/gui-perf-probe.js').read_bytes()== (ROOT/'site/preview-v2/assets/gui-perf-probe.js').read_bytes(), 'opt-in performance probe was not copied byte-for-byte') +expected=apply_authoritative_fx_power(expected) # Stage C: the source HTML remains byte-exact, but the 18 deployed CSS files # contain only proven cascade winners. Verify every *generated* byte and query # hash; never approve an extra stylesheet, different owner or PNG mutation. diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 4a813197c..a318df81a 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -20,6 +20,7 @@ // B-stage: attached-node-only meter caches; a structural render invalidates // them atomically. Never retain detached WebView2 strips or stale channel IDs. const meterElements = new Map(); + let nativeFxPowerSerial=0, pendingNativeFxPower=null; let controller = null; const status = message => { lastNativeError = message; @@ -97,6 +98,7 @@ (out?.name||"SOURCE ONLY (No Main)"); } t.selected=previous.get(t.id)?.selected || false; + if(typeof ch.fxRackBypassed==="boolean")t.fxOn=!ch.fxRackBypassed; if (Array.isArray(ch.inserts)) { t.fx=Array.from({length:8},(_,i)=>ch.inserts[i]?.name||"None"); t.slotBypass=Array.from({length:8},(_,i)=>Boolean(ch.inserts[i]?.bypassed)); @@ -342,6 +344,8 @@ hardware.device.enabledOutputs.length>=2 && legacy()?.active===true); function updateHardwarePanel(next) { hardware=next || null; + nativeStream=next?.raw?.secondaryOutput || null; + renderStreamPanel(); refreshRealM4Inputs(next); const d=next?.device; const deviceOpen=Boolean(d?.backend && d.sampleRate>0 && @@ -416,6 +420,7 @@ // replaces the 740x590 default JUCE dialog for normal operator setup. let devicePanel=null,deviceInventory=null,deviceBusy=false, deviceRequest=0,pendingDeviceMute=null,deviceChoice=null,deviceResult=""; + let nativeStream=null,streamChoice="",streamBusyId="",streamSeq=0,pendingStreamMute=null,streamNotice=""; function openNativeAudioIO(){ if(!devicePanel){ const style=document.createElement("style"); @@ -426,7 +431,10 @@ .armix-audio-dialog{background:#142631;border:1px solid #467083;border-radius:8px; box-shadow:0 16px 56px #0009;color:#e3eff4;width:min(480px,94vw); padding:17px;display:grid;gap:11px;font:12px system-ui,sans-serif} + .armix-audio-dialog{max-height:90dvh;overflow-y:auto} .armix-audio-dialog h2{font-size:16px;font-weight:600;margin:0} + .armix-stream-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:7px} + .armix-stream-status{font-size:11px;color:#b4d5e0;line-height:1.5;margin-top:5px} .armix-audio-dialog label{display:grid;gap:5px;color:#a9c5d2} .armix-audio-dialog select{background:#09202c;border:1px solid #476778; border-radius:4px;color:#edf9ff;min-height:30px;width:100%;padding:3px 7px} @@ -453,6 +461,19 @@
Reading current audio device…
The output device above is the real destination. A virtual cable does not automatically play through headphones.
+
+ STREAM · optional output for OBS / TikTok + +
STREAM OFF · no separate endpoint connected
+
+ + + +
+
STREAM sends one post-FX MAIN copy to a separate render endpoint, + never replacing the physical monitor. Selecting CABLE Input does not + confirm OBS/TikTok is receiving sound. An independent clock adds buffering.
+
Advanced · rate, buffer and channel pins @@ -502,8 +523,60 @@ else if(field==="buffer")deviceChoice.buffer=Number(e.target.value)||0; renderDevicePanel(); }); + devicePanel.addEventListener("change",e=>{ + if(e.target?.matches?.("[data-stream-endpoint]")){ + streamChoice=e.target.value;streamNotice="";renderStreamPanel(); + } + }); + devicePanel.addEventListener("click",e=>{ + const action=e.target?.dataset?.streamAction; + if(!action)return; + if(action==="stop"){ + pendingStreamMute=null; + sendStreamAction("secondaryOutputStop",null);return; + } + if(action==="live"){ + if(nativeStream?.ready!==true||nativeStream?.fault===true|| + !nativeStream?.endpoint||streamBusyId){ + streamNotice="Connect a healthy output before going live";renderStreamPanel();return; + } + sendStreamAction("secondaryOutputArm",true);return; + } + if(action!=="connect"||streamBusyId||pendingStreamMute)return; + const target=streamChoice,outputs=streamPlaybackChoices(); + const capture=String(hardware?.device?.captureDevice||"").toLowerCase(); + const lower=target.toLowerCase(); + const sameCable=capture.includes("cable output") && lower.includes("cable input") && + (capture.includes("vb-audio")||lower.includes("vb-audio")); + if(!outputs.includes(target)||target===hardware?.device?.playbackDevice|| + sameCable||legacy()?.routeAccepted!==true||!deviceReady()){ + streamNotice=sameCable?"STREAM blocked: VB-Cable input/output feedback loop": + "Select a separate endpoint after routing real hardware input"; + renderStreamPanel();return; + } + if(hardware?.device?.outputArmed){ + const epoch=safeNativeCounter(hardware?.device?.epoch); + if(epoch===null)return; + const requestId="stream-mute-"+(++streamSeq); + pendingStreamMute={requestId,epoch:String(epoch),target}; + streamNotice="Muting physical MAIN before connecting STREAM…"; + backend.emitEvent("arMixAction",{action:"monitor",value:false,requestId}); + window.setTimeout(()=>{ + if(pendingStreamMute?.requestId!==requestId)return; + pendingStreamMute=null; + streamNotice="STREAM cancelled: physical MUTE was not acknowledged"; + renderStreamPanel(); + },8000); + renderStreamPanel();return; + } + sendStreamAction("secondaryOutputConnect",target); + }); devicePanel.querySelector("[data-audio-apply]").onclick=()=>{ if(deviceBusy||pendingDeviceMute||!deviceChoice||!deviceInventory?.active)return; + if(nativeStream?.armed){ + deviceResult="Stop STREAM before changing the primary device"; + renderDevicePanel();return; + } const draft=deviceChoice,active=deviceInventory.active; if(!draft.backend||!draft.capture||!draft.playback)return; if(hardware?.device?.outputArmed){ @@ -605,7 +678,67 @@ "No verified audio device. Select a supported input and output."); devicePanel.querySelector("[data-audio-apply]").disabled=deviceBusy|| !!pendingDeviceMute||!deviceChoice.backend||!deviceChoice.capture|| - !deviceChoice.playback; + !deviceChoice.playback||nativeStream?.armed===true; + renderStreamPanel(); + } + function streamPlaybackChoices(){ + const type=deviceInventory?.types?.find(t=>t.name==="Windows Audio"); + return Array.isArray(type?.outputs)?type.outputs.filter( + x=>typeof x==="string"&&x.length>0):[]; + } + // All displayed STREAM states come from the real native WASAPI consumer + // snapshot. An ACK only triggers a later readback, not an optimistic ON. + function renderStreamPanel(){ + const select=devicePanel?.querySelector("[data-stream-endpoint]"); + if(!select)return; + const options=streamPlaybackChoices(); + if(!options.includes(streamChoice)) + streamChoice=options.includes(nativeStream?.endpoint)?nativeStream.endpoint:(options[0]||""); + const signature=options.join("\\0"); + if(select.dataset.inventory!==signature){ + select.dataset.inventory=signature; + select.replaceChildren(...options.map(name=>{ + const item=document.createElement("option");item.value=name; + item.textContent=name;return item; + })); + } + if(select.value!==streamChoice)select.value=streamChoice; + const ready=nativeStream?.ready===true&&nativeStream?.fault!==true; + const live=ready&&nativeStream?.armed===true; + const endpoint=String(nativeStream?.endpoint||""); + const indicator=devicePanel.querySelector("[data-stream-status]"); + if(indicator)indicator.textContent=streamNotice|| + (nativeStream?.fault?"STREAM FAULT · Stop / Disconnect and reconnect": + live?"STREAM ON · "+endpoint+" · WASAPI render (receiver unverified)": + ready?"STREAM CONNECTED / OFF · "+endpoint: + "STREAM OFF · choose a separate output endpoint"); + const connect=devicePanel.querySelector('[data-stream-action="connect"]'); + const go=devicePanel.querySelector('[data-stream-action="live"]'); + const stop=devicePanel.querySelector('[data-stream-action="stop"]'); + if(connect)connect.disabled=!!streamBusyId||!!pendingStreamMute|| + !deviceReady()||legacy()?.routeAccepted!==true||!streamChoice|| + streamChoice===hardware?.device?.playbackDevice; + if(go)go.disabled=!!streamBusyId||!!pendingStreamMute||!ready||live; + if(stop)stop.disabled=!streamBusyId&&!pendingStreamMute&&!ready&&!nativeStream?.armed; + select.disabled=!!streamBusyId||!!pendingStreamMute; + } + function sendStreamAction(action,value){ + if(streamBusyId&&action!=="secondaryOutputStop")return; + const epoch=safeNativeCounter(hardware?.device?.epoch); + if(action!=="secondaryOutputStop"&&epoch===null)return; + const requestId="stream-"+(++streamSeq); + streamBusyId=requestId; + streamNotice=action==="secondaryOutputStop"?"Stopping STREAM…": + action==="secondaryOutputConnect"?"Connecting WASAPI output…": + "Enabling STREAM; awaiting real consumer readback…"; + backend.emitEvent("arMixAction",{action,requestId,value, + ...(epoch===null?{}:{expectedDeviceEpoch:epoch})}); + window.setTimeout(()=>{ + if(streamBusyId!==requestId)return; + streamBusyId="";streamNotice="STREAM response timed out; refreshing actual state"; + controller?.subscribe();renderStreamPanel(); + },8000); + renderStreamPanel(); } function sendDeviceApply(){ if(!deviceChoice||!deviceInventory?.active)return; @@ -632,6 +765,13 @@ if(!deviceBusy)deviceChoice=null; renderDevicePanel(); }); + backend.addEventListener("arMixSecondaryOutputAck",ack=>{ + if(!streamBusyId||ack?.requestId!==streamBusyId)return; + streamBusyId=""; + streamNotice=ack.ok===true&&ack.deviceEpoch===String(hardware?.device?.epoch||"")? + "":("STREAM REJECTED · "+(ack?.error||"device changed; refresh")); + controller?.subscribe();renderStreamPanel(); + }); backend.addEventListener("arMixAudioDeviceApplyAck",ack=>{ if(!devicePanel||ack?.requestId!==devicePanel.dataset.pendingRequest)return; deviceBusy=false; @@ -761,7 +901,7 @@ // Control readback may change at the SAME structural graph revision. // Compare the actual accepted controls/edges, never skip native fader updates. const signature=next.identity+"|"+JSON.stringify(next.graph.channels.map(ch=>[ - ch.id,ch.controls,ch.inserts,ch.primaryOutId]))+"|"+JSON.stringify(next.graph.edges); + ch.id,ch.controls,ch.inserts,ch.fxRackBypassed,ch.primaryOutId]))+"|"+JSON.stringify(next.graph.edges); if (signature===lastPaintedSignature) { // Telemetry often advances without a structural graph revision. paintNativeMeters(next); @@ -774,6 +914,12 @@ } flags.productionCallbackLive=next.productLive;flags.acceptedGraphConnected=true; lastPaintedSignature=signature;stopDemo();paintNativeMeters(next); + if(pendingNativeFxPower?.acked){ + const p=pendingNativeFxPower,ch=next.graph.channels.find(c=>c.id===p.channelId); + const actual=p.kind==="rack"?ch?.fxRackBypassed: + ch?.inserts?.find(i=>i.id===p.insertId)?.bypassed; + if(actual===p.bypassed){pendingNativeFxPower=null;status("NATIVE FX power verified from PCM readback");} + } status((next.productLive?"NATIVE PRODUCT LIVE":"NATIVE PCM GRAPH ACCEPTED · FAT PENDING")+ " · device "+next.device.epoch+ " · graph "+next.graph.revision+" · roster "+next.graph.rosterRevision); @@ -806,6 +952,16 @@ finally{profiler.sample("nativeSnapshotJsMs",performance.now()-started);} }); backend.addEventListener("arMixConsoleAck", ack=>controller.onAck(ack)); + backend.addEventListener("arMixNativeFxPowerAck", ack=>{ + if(!pendingNativeFxPower||ack?.requestId!==pendingNativeFxPower.requestId)return; + if(ack?.ok!==true){ + pendingNativeFxPower=null; + status("NATIVE FX REJECTED: "+(ack?.error||"stale engine authority")); + controller.subscribe();return; + } + pendingNativeFxPower.acked=true; + controller.subscribe(); // a later PCM-producer snapshot is required + }); backend.addEventListener("arMixSourceSwitchAck", ack=>{ if(nativeUiSourcePending && ack?.requestId===nativeUiSourcePending.requestId) { @@ -871,6 +1027,17 @@ controller.subscribe(); }); backend.addEventListener("arMixAudioArmAck", ack=>{ + if(pendingStreamMute){ + if(ack?.requestId!==pendingStreamMute.requestId)return; + const pending=pendingStreamMute;pendingStreamMute=null; + if(ack.ok===true&&ack.armed===false&&String(ack.deviceEpoch)===pending.epoch){ + sendStreamAction("secondaryOutputConnect",pending.target); + }else{ + streamNotice="STREAM cancelled: physical MUTE not verified"; + renderStreamPanel(); + } + return; + } if(pendingDeviceMute){ // Reject any stale/unrelated ACK and any device epoch change. if(ack?.requestId!==pendingDeviceMute.requestId)return; @@ -1053,6 +1220,36 @@ const key=action==="mute"?"SET_MUTE":"SET_SOLO"; intent(key,t,{value:!t[action],enabled:!t[action]});return true; } + if(action==="fxOn" || action==="slotPower") { + const current=controller?.state()?.current,id=nativeIdFor(t); + const ch=current?.graph?.channels?.find(x=>x.id===id); + if(!current?.admitted||!id||!ch||pendingNativeFxPower){ + status("NATIVE FX: wait for accepted graph/readback or pending ACK");return true; + } + const rack=action==="fxOn",slot=Number(btn?.dataset?.slot); + const insert=!rack&&Number.isInteger(slot)&&slot>=0&&slot<8?ch.inserts?.[slot]:null; + if((rack&&typeof ch.fxRackBypassed!=="boolean")|| + (!rack&&(!insert||typeof insert.bypassed!=="boolean"||typeof insert.id!=="string"||!insert.id))){ + status("NATIVE FX: insert or rack not admitted");return true; + } + const requestId="fx-"+(++nativeFxPowerSerial)+"-"+Date.now().toString(36); + const bypassed=rack?!ch.fxRackBypassed:!insert.bypassed; + pendingNativeFxPower={requestId,channelId:id,kind:rack?"rack":"insert", + insertId:insert?.id,bypassed,acked:false}; + backend.emitEvent("arMixAction",{ + action:rack?"routingNativeFxRackBypass":"routingNativeFxInsertBypass", + requestId,channelId:id,deviceEpoch:current.device.epoch, + revision:current.graph.revision,value:bypassed, + ...(rack?{}:{slot,insertId:insert.id}) + }); + status("NATIVE FX "+(rack?"RACK":"INSERT")+" pending ACK and PCM readback"); + window.setTimeout(()=>{ + if(pendingNativeFxPower?.requestId===requestId){ + pendingNativeFxPower=null;controller?.subscribe(); + status("NATIVE FX ACK/readback timeout; restoring verified state"); + } + },8000);return true; + } status("NATIVE: "+action+" is not an accepted ChannelId operation");return true; }, consumeWire(ops) { @@ -1062,6 +1259,12 @@ !current.graph.capabilities.supportedOps.includes("APPLY_WIRE_TRANSACTION")) { status("NATIVE: WIRE transaction not admitted; graph unchanged");return true; } + // Structural PCM topology edits require BOTH physical and virtual + // outputs disarmed. Never auto-mute a live show. + if(hardware?.device?.outputArmed===true || nativeStream?.armed===true){ + status("WIRE requires MONITOR OFF and STREAM stopped; route unchanged"); + return true; + } const changes=[]; for (const op of ops) { const sourceId=nativeByUiId.get(op.sourceId);