Skip to content

Commit ac7b829

Browse files
committed
Add unit test for IONode minimum audio port count
Verifies that Audio Input/Output nodes receive a minimum of 2 ports when added to a graph with zero audio ports configured.
1 parent a305095 commit ac7b829

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/audioroutingtests.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,4 +1032,33 @@ BOOST_AUTO_TEST_CASE (AudioFeedbackPrevention)
10321032
BOOST_REQUIRE (! feedbackAllowed);
10331033
}
10341034

1035+
BOOST_AUTO_TEST_CASE (IONodeMinimumAudioPortCount)
1036+
{
1037+
// Test that Audio I/O nodes get a minimum port count when added to a graph with zero audio ports
1038+
// This prevents the bug where Audio Input/Output nodes appear with zero ports
1039+
1040+
PreparedGraph fix;
1041+
GraphNode& graph = fix.graph;
1042+
1043+
fix.graph.clear();
1044+
graph.setNumPorts (PortType::Audio, 0, true, false);
1045+
graph.setNumPorts (PortType::Audio, 0, false, false);
1046+
1047+
// Verify graph starts with zero audio ports configured
1048+
BOOST_REQUIRE_EQUAL (graph.getNumPorts (PortType::Audio, true), 0);
1049+
BOOST_REQUIRE_EQUAL (graph.getNumPorts (PortType::Audio, false), 0);
1050+
1051+
// Add Audio Input node - should set graph audio inputs to minimum 2 (stereo)
1052+
auto* audioIn = new IONode (IONode::audioInputNode);
1053+
graph.addNode (audioIn);
1054+
BOOST_REQUIRE_EQUAL (graph.getNumPorts (PortType::Audio, true), 2);
1055+
BOOST_REQUIRE_EQUAL (audioIn->getNumPorts(), 2);
1056+
1057+
// Add Audio Output node - should set graph audio outputs to minimum 2 (stereo)
1058+
auto* audioOut = new IONode (IONode::audioOutputNode);
1059+
graph.addNode (audioOut);
1060+
BOOST_REQUIRE_EQUAL (graph.getNumPorts (PortType::Audio, false), 2);
1061+
BOOST_REQUIRE_EQUAL (audioOut->getNumPorts(), 2);
1062+
}
1063+
10351064
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)