Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion engine/core/DynamicAcceptedSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class DynamicAcceptedSession final {
result.native.fault=DynamicNativeSessionPublisher::Fault::invalidCandidate;
result.native.revision=publisher_.acceptedRevision();
result.edit.createdIds.clear();
result.edit.createdEdgeIds.clear();
return result;
}
// A structural OUT/GROUP/Return edit does NOT implicitly change IN.
Expand All @@ -284,6 +285,7 @@ class DynamicAcceptedSession final {
result.native.graphError={DynamicGraphFault::invalidSource,source.id};
result.native.revision=publisher_.acceptedRevision();
result.edit.createdIds.clear();
result.edit.createdEdgeIds.clear();
return result; // old audible SOURCE and VST3 leases unchanged
}
}
Expand All @@ -294,7 +296,8 @@ class DynamicAcceptedSession final {
std::move(fx));
if(!result.native.ok()) {
result.fault=Fault::graphRejected;
result.edit.createdIds.clear(); // NEVER advertise phantom Bus
result.edit.createdIds.clear();
result.edit.createdEdgeIds.clear(); // NEVER advertise phantom Bus
return result; // candidate destroyed; accepted state intact
}
static_assert(std::is_nothrow_move_assignable_v<DynamicChannelRoster>);
Expand Down
13 changes: 10 additions & 3 deletions engine/core/DynamicChannelRoster.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,16 @@ class DynamicChannelRoster final {
result.fault=ChannelEditFault::invalidValue;break;
}
auto& edges=it->sends;
edges.erase(std::remove_if(edges.begin(),edges.end(),
[](const auto& x){return x.primaryOutput;}),edges.end());
if(op.target.value) {
const auto primary=std::find_if(edges.begin(),edges.end(),
[](const auto& x){return x.primaryOutput;});
if(!op.target.value) {
if(primary!=edges.end())edges.erase(primary);
} else if(primary!=edges.end()) {
// A replug/OUT retarget is still ONE physical edge.
// Keep stable identity on identical or changed target.
primary->destination=op.target;
primary->gain=1.f;primary->preFader=false;primary->pan=0.f;
} else {
if(edges.size()>=budget_.maximumSendsPerChannel) {
result.fault=ChannelEditFault::budgetExceeded;break;
}
Expand Down
55 changes: 55 additions & 0 deletions tests/dynamic_accepted_session_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ static void verifyAtomicWireTransactionAndZeroSampleHops() {
const std::array<WireChange,1> feedback{connect(three,one)};
rejected=session.wireTransaction(6,6,feedback,physical,epoch,epoch,true);
assert(rejected.fault==DynamicAcceptedSession::Fault::graphRejected);
// An uncommitted edge is not a native/GUI identity: rollback clears it.
assert(rejected.edit.createdEdgeIds.empty());
assert(session.acceptedGraphRevision()==6);
assert(render() && near(left[11],.3f*center));
rejected=session.wireTransaction(5,5,unplug,physical,epoch,epoch,true);
Expand Down Expand Up @@ -371,7 +373,60 @@ static void verifyDefaultNativeMainEdgeAndDisconnectedRestore() {
session.unpublish();session.pollRetirement();
}


// Legacy OUT selectors must project the SAME edgeId as native WIRE.
// Clicking an unchanged MAIN target or rerouting its occupied plug does NOT
// create a different edge and does not change the admitted PCM sum.
static void verifyPrimaryOutKeepsCanonicalEdgeIdentity() {
constexpr std::uint64_t epoch=9931;
DynamicAcceptedSession session;
DynamicGraphRequest physical;
physical.physicalInputs=1;physical.maxFrames=64;
const std::array<ChannelEdit,3> first{
add(0,ChannelRole::input,"SOURCE"),
add(1,ChannelRole::input,"INTERMEDIATE",ProcessingFormat::stereo),
add(2,ChannelRole::main,"MAIN",ProcessingFormat::stereo)
};
auto a=session.edit(0,0,first,physical,epoch,epoch,true);
assert(a.ok());
const auto src=a.edit.createdIds[0],via=a.edit.createdIds[1];
const auto main=a.edit.createdIds[2];
const std::array<ChannelEdit,2> initial{output(src,main),output(via,main)};
physical.sources={{src,0,-1,false}};
a=session.edit(1,1,initial,physical,epoch,epoch,true);
assert(a.ok());
const auto* accepted=session.acceptedRouting(epoch,2);
assert(accepted&&accepted->edges.size()==2);
const auto edgeId=accepted->edges[0].edgeId;
const auto viaId=accepted->edges[1].edgeId;
assert(edgeId!=0&&viaId!=0&&edgeId!=viaId);
std::array<float,64> impulse{},left{},right{};
impulse[19]=.25f;
const float* pins[]{impulse.data()};
const auto noFx=+[](ChannelId,float*,float*,int) noexcept {};
const auto render=[&] {
return session.render(epoch,pins,1,left.data(),right.data(),64,false,noFx);
};
assert(render() && near(left[19],.25f*.7071067811865475f));
const std::array<ChannelEdit,1> same{output(src,main)};
a=session.edit(2,2,same,physical,epoch,epoch,true);
assert(a.ok());
assert(session.acceptedRouting(epoch,3)->edges[0].edgeId==edgeId);
assert(render() && near(left[19],.25f*.7071067811865475f));
const std::array<ChannelEdit,1> retarget{output(src,via)};
a=session.edit(3,3,retarget,physical,epoch,epoch,true);
assert(a.ok());
accepted=session.acceptedRouting(epoch,4);
assert(accepted->edges[0].edgeId==edgeId);
assert(accepted->edges[0].to==via);
assert(accepted->edges[1].edgeId==viaId);
assert(render() && near(left[19],.25f*.7071067811865475f));
session.unpublish();
session.pollRetirement();
}

int main() {
verifyPrimaryOutKeepsCanonicalEdgeIdentity();
verifyDefaultNativeMainEdgeAndDisconnectedRestore();
verifyAtomicWireTransactionAndZeroSampleHops();

Expand Down
Loading