|
@@ -18,6 +18,10 @@ from observe_pipewire import (
|
|
|
CAPTURE_0 = "alsa_input.hw_U192k_0:capture_AUX0"
|
|
CAPTURE_0 = "alsa_input.hw_U192k_0:capture_AUX0"
|
|
|
CAPTURE_2 = "alsa_input.hw_U192k_0:capture_AUX2"
|
|
CAPTURE_2 = "alsa_input.hw_U192k_0:capture_AUX2"
|
|
|
CAPTURE_3 = "alsa_input.hw_U192k_0:capture_AUX3"
|
|
CAPTURE_3 = "alsa_input.hw_U192k_0:capture_AUX3"
|
|
|
|
|
+AMP_INPUT = "effect_0:input"
|
|
|
|
|
+AMP_OUTPUT = "effect_0:output"
|
|
|
|
|
+CAB_INPUT = "effect_1:in"
|
|
|
|
|
+CAB_OUTPUT = "effect_1:out"
|
|
|
MIX_INPUT_0 = "rigforge.direct-mix.input:playback_AUX0"
|
|
MIX_INPUT_0 = "rigforge.direct-mix.input:playback_AUX0"
|
|
|
MIX_INPUT_2 = "rigforge.direct-mix.input:playback_AUX2"
|
|
MIX_INPUT_2 = "rigforge.direct-mix.input:playback_AUX2"
|
|
|
MIX_OUTPUT = "rigforge.direct-mix.output:capture_FL"
|
|
MIX_OUTPUT = "rigforge.direct-mix.output:capture_FL"
|
|
@@ -79,18 +83,22 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
]
|
|
]
|
|
|
self.assertTrue(any("approved observed Rigforge or UMC port" in error for error in validate_managed_links(state)))
|
|
self.assertTrue(any("approved observed Rigforge or UMC port" in error for error in validate_managed_links(state)))
|
|
|
|
|
|
|
|
- def test_declared_filter_mix_links_are_valid_and_match_observed_graph(self):
|
|
|
|
|
|
|
+ def test_declared_guitar_effect_chain_and_voice_mix_links_match_observed_graph(self):
|
|
|
links = {
|
|
links = {
|
|
|
- (CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
|
}
|
|
}
|
|
|
self.assertEqual(validate_managed_links(self.state), [])
|
|
self.assertEqual(validate_managed_links(self.state), [])
|
|
|
self.assertEqual(observe(self.state, links), [])
|
|
self.assertEqual(observe(self.state, links), [])
|
|
|
|
|
|
|
|
- def test_reports_missing_filter_mix_link(self):
|
|
|
|
|
|
|
+ def test_reports_missing_voice_mix_link_without_expectation_of_dry_guitar(self):
|
|
|
links = {
|
|
links = {
|
|
|
- (CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
|
}
|
|
}
|
|
|
reports = observe(self.state, links)
|
|
reports = observe(self.state, links)
|
|
@@ -110,7 +118,9 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
state = copy.deepcopy(self.state)
|
|
state = copy.deepcopy(self.state)
|
|
|
state["routing"]["managed_ports"].append(CAPTURE_3)
|
|
state["routing"]["managed_ports"].append(CAPTURE_3)
|
|
|
links = {
|
|
links = {
|
|
|
- (CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
|
(CAPTURE_3, MIX_INPUT_2),
|
|
(CAPTURE_3, MIX_INPUT_2),
|
|
@@ -134,7 +144,9 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
def runner(command, **kwargs):
|
|
def runner(command, **kwargs):
|
|
|
calls.append(command)
|
|
calls.append(command)
|
|
|
return SimpleNamespace(stdout=(
|
|
return SimpleNamespace(stdout=(
|
|
|
- f"{CAPTURE_0}\n |-> {MIX_INPUT_0}\n"
|
|
|
|
|
|
|
+ f"{CAPTURE_0}\n |-> {AMP_INPUT}\n"
|
|
|
|
|
+ f"{AMP_OUTPUT}\n |-> {CAB_INPUT}\n"
|
|
|
|
|
+ f"{CAB_OUTPUT}\n |-> {MIX_INPUT_0}\n"
|
|
|
f"{CAPTURE_2}\n |-> {MIX_INPUT_2}\n"
|
|
f"{CAPTURE_2}\n |-> {MIX_INPUT_2}\n"
|
|
|
f"{MIX_OUTPUT}\n |-> {PLAYBACK_0}\n"
|
|
f"{MIX_OUTPUT}\n |-> {PLAYBACK_0}\n"
|
|
|
))
|
|
))
|
|
@@ -148,7 +160,9 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
def test_reconcile_once_links_only_declared_missing_edges_and_verifies(self):
|
|
def test_reconcile_once_links_only_declared_missing_edges_and_verifies(self):
|
|
|
state = copy.deepcopy(self.state)
|
|
state = copy.deepcopy(self.state)
|
|
|
links = {
|
|
links = {
|
|
|
- (CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
|
}
|
|
}
|
|
|
calls = []
|
|
calls = []
|
|
@@ -161,9 +175,13 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
if command == ["pw-link", "-l"]:
|
|
if command == ["pw-link", "-l"]:
|
|
|
return SimpleNamespace(stdout=render_links())
|
|
return SimpleNamespace(stdout=render_links())
|
|
|
if command == ["pw-link", "-o"]:
|
|
if command == ["pw-link", "-o"]:
|
|
|
- return SimpleNamespace(stdout=f"{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_OUTPUT}\n{CAB_OUTPUT}\n{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n"
|
|
|
|
|
+ ))
|
|
|
if command == ["pw-link", "-i"]:
|
|
if command == ["pw-link", "-i"]:
|
|
|
- return SimpleNamespace(stdout=f"{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_INPUT}\n{CAB_INPUT}\n{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n"
|
|
|
|
|
+ ))
|
|
|
if command == ["pw-link", CAPTURE_2, MIX_INPUT_2]:
|
|
if command == ["pw-link", CAPTURE_2, MIX_INPUT_2]:
|
|
|
links.add((CAPTURE_2, MIX_INPUT_2))
|
|
links.add((CAPTURE_2, MIX_INPUT_2))
|
|
|
return SimpleNamespace(stdout="")
|
|
return SimpleNamespace(stdout="")
|
|
@@ -190,11 +208,17 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
if command == ["pw-link", "-l"]:
|
|
if command == ["pw-link", "-l"]:
|
|
|
return SimpleNamespace(stdout=render_links())
|
|
return SimpleNamespace(stdout=render_links())
|
|
|
if command == ["pw-link", "-o"]:
|
|
if command == ["pw-link", "-o"]:
|
|
|
- return SimpleNamespace(stdout=f"{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_OUTPUT}\n{CAB_OUTPUT}\n{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n"
|
|
|
|
|
+ ))
|
|
|
if command == ["pw-link", "-i"]:
|
|
if command == ["pw-link", "-i"]:
|
|
|
- return SimpleNamespace(stdout=f"{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_INPUT}\n{CAB_INPUT}\n{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n"
|
|
|
|
|
+ ))
|
|
|
if tuple(command) in {
|
|
if tuple(command) in {
|
|
|
- ("pw-link", CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ ("pw-link", AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ ("pw-link", CAB_OUTPUT, MIX_INPUT_0),
|
|
|
|
|
+ ("pw-link", CAPTURE_0, AMP_INPUT),
|
|
|
("pw-link", CAPTURE_2, MIX_INPUT_2),
|
|
("pw-link", CAPTURE_2, MIX_INPUT_2),
|
|
|
("pw-link", MIX_OUTPUT, PLAYBACK_0),
|
|
("pw-link", MIX_OUTPUT, PLAYBACK_0),
|
|
|
}:
|
|
}:
|
|
@@ -207,8 +231,10 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
|
result["actions"],
|
|
result["actions"],
|
|
|
[
|
|
[
|
|
|
- {"kind": "link", "from": CAPTURE_0, "to": MIX_INPUT_0, "result": "requested"},
|
|
|
|
|
|
|
+ {"kind": "link", "from": CAPTURE_0, "to": AMP_INPUT, "result": "requested"},
|
|
|
{"kind": "link", "from": CAPTURE_2, "to": MIX_INPUT_2, "result": "requested"},
|
|
{"kind": "link", "from": CAPTURE_2, "to": MIX_INPUT_2, "result": "requested"},
|
|
|
|
|
+ {"kind": "link", "from": AMP_OUTPUT, "to": CAB_INPUT, "result": "requested"},
|
|
|
|
|
+ {"kind": "link", "from": CAB_OUTPUT, "to": MIX_INPUT_0, "result": "requested"},
|
|
|
{"kind": "link", "from": MIX_OUTPUT, "to": PLAYBACK_0, "result": "requested"},
|
|
{"kind": "link", "from": MIX_OUTPUT, "to": PLAYBACK_0, "result": "requested"},
|
|
|
],
|
|
],
|
|
|
)
|
|
)
|
|
@@ -216,15 +242,24 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
|
[command for command in calls if len(command) == 3 and command[0] == "pw-link"],
|
|
[command for command in calls if len(command) == 3 and command[0] == "pw-link"],
|
|
|
[
|
|
[
|
|
|
- ["pw-link", CAPTURE_0, MIX_INPUT_0],
|
|
|
|
|
|
|
+ ["pw-link", CAPTURE_0, AMP_INPUT],
|
|
|
["pw-link", CAPTURE_2, MIX_INPUT_2],
|
|
["pw-link", CAPTURE_2, MIX_INPUT_2],
|
|
|
|
|
+ ["pw-link", AMP_OUTPUT, CAB_INPUT],
|
|
|
|
|
+ ["pw-link", CAB_OUTPUT, MIX_INPUT_0],
|
|
|
["pw-link", MIX_OUTPUT, PLAYBACK_0],
|
|
["pw-link", MIX_OUTPUT, PLAYBACK_0],
|
|
|
],
|
|
],
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
def test_reconcile_once_does_not_link_when_endpoint_is_unavailable(self):
|
|
def test_reconcile_once_does_not_link_when_endpoint_is_unavailable(self):
|
|
|
state = copy.deepcopy(self.state)
|
|
state = copy.deepcopy(self.state)
|
|
|
- links = {(CAPTURE_0, MIX_INPUT_0), (MIX_OUTPUT, PLAYBACK_0)}
|
|
|
|
|
|
|
+ links = {
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
|
|
+ (CAPTURE_2, MIX_INPUT_2),
|
|
|
|
|
+ (MIX_OUTPUT, PLAYBACK_0),
|
|
|
|
|
+ }
|
|
|
|
|
+ links.remove((CAPTURE_2, MIX_INPUT_2))
|
|
|
calls = []
|
|
calls = []
|
|
|
|
|
|
|
|
def render_links():
|
|
def render_links():
|
|
@@ -235,9 +270,11 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
if command == ["pw-link", "-l"]:
|
|
if command == ["pw-link", "-l"]:
|
|
|
return SimpleNamespace(stdout=render_links())
|
|
return SimpleNamespace(stdout=render_links())
|
|
|
if command == ["pw-link", "-o"]:
|
|
if command == ["pw-link", "-o"]:
|
|
|
- return SimpleNamespace(stdout=f"{CAPTURE_0}\n{MIX_OUTPUT}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=f"{AMP_OUTPUT}\n{CAB_OUTPUT}\n{CAPTURE_0}\n{MIX_OUTPUT}\n")
|
|
|
if command == ["pw-link", "-i"]:
|
|
if command == ["pw-link", "-i"]:
|
|
|
- return SimpleNamespace(stdout=f"{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_INPUT}\n{CAB_INPUT}\n{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n"
|
|
|
|
|
+ ))
|
|
|
self.fail(f"unexpected command: {command}")
|
|
self.fail(f"unexpected command: {command}")
|
|
|
|
|
|
|
|
result = reconcile_once(state, runner)
|
|
result = reconcile_once(state, runner)
|
|
@@ -258,7 +295,9 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
state = copy.deepcopy(self.state)
|
|
state = copy.deepcopy(self.state)
|
|
|
state["routing"]["managed_ports"].append(CAPTURE_3)
|
|
state["routing"]["managed_ports"].append(CAPTURE_3)
|
|
|
links = {
|
|
links = {
|
|
|
- (CAPTURE_0, MIX_INPUT_0),
|
|
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
(CAPTURE_2, MIX_INPUT_2),
|
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
(MIX_OUTPUT, PLAYBACK_0),
|
|
|
(CAPTURE_3, MIX_INPUT_2),
|
|
(CAPTURE_3, MIX_INPUT_2),
|
|
@@ -280,7 +319,12 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_reconcile_once_reports_link_still_missing_after_request(self):
|
|
def test_reconcile_once_reports_link_still_missing_after_request(self):
|
|
|
state = copy.deepcopy(self.state)
|
|
state = copy.deepcopy(self.state)
|
|
|
- links = {(CAPTURE_0, MIX_INPUT_0), (MIX_OUTPUT, PLAYBACK_0)}
|
|
|
|
|
|
|
+ links = {
|
|
|
|
|
+ (CAPTURE_0, AMP_INPUT),
|
|
|
|
|
+ (AMP_OUTPUT, CAB_INPUT),
|
|
|
|
|
+ (CAB_OUTPUT, MIX_INPUT_0),
|
|
|
|
|
+ (MIX_OUTPUT, PLAYBACK_0),
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
def render_links():
|
|
def render_links():
|
|
|
return "".join(f"{source}\n |-> {destination}\n" for source, destination in sorted(links))
|
|
return "".join(f"{source}\n |-> {destination}\n" for source, destination in sorted(links))
|
|
@@ -289,9 +333,13 @@ class PipeWireObserverTests(unittest.TestCase):
|
|
|
if command == ["pw-link", "-l"]:
|
|
if command == ["pw-link", "-l"]:
|
|
|
return SimpleNamespace(stdout=render_links())
|
|
return SimpleNamespace(stdout=render_links())
|
|
|
if command == ["pw-link", "-o"]:
|
|
if command == ["pw-link", "-o"]:
|
|
|
- return SimpleNamespace(stdout=f"{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_OUTPUT}\n{CAB_OUTPUT}\n{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n"
|
|
|
|
|
+ ))
|
|
|
if command == ["pw-link", "-i"]:
|
|
if command == ["pw-link", "-i"]:
|
|
|
- return SimpleNamespace(stdout=f"{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n")
|
|
|
|
|
|
|
+ return SimpleNamespace(stdout=(
|
|
|
|
|
+ f"{AMP_INPUT}\n{CAB_INPUT}\n{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n"
|
|
|
|
|
+ ))
|
|
|
if command == ["pw-link", CAPTURE_2, MIX_INPUT_2]:
|
|
if command == ["pw-link", CAPTURE_2, MIX_INPUT_2]:
|
|
|
return SimpleNamespace(stdout="")
|
|
return SimpleNamespace(stdout="")
|
|
|
self.fail(f"unexpected command: {command}")
|
|
self.fail(f"unexpected command: {command}")
|