Commit 9d16dcdd by PLN (Algolia)

autoroute: re-point the black box when Master moves to another sink

The recorder resolves its sink once, at start. Master following the default
output would otherwise leave it recording the old sink's monitor: silence,
reported as RUNNING. try-restart only touches a recorder that is already
running.
parent 4861e614
...@@ -49,6 +49,8 @@ def _reconcile(tmp_path, lo, inputs=INPUTS, default_sink=SINK, extra_env=None, s ...@@ -49,6 +49,8 @@ def _reconcile(tmp_path, lo, inputs=INPUTS, default_sink=SINK, extra_env=None, s
*) echo "$@" >> '{calls}' ;; *) echo "$@" >> '{calls}' ;;
esac esac
""")) """))
sc_calls = tmp_path / "systemctl.calls"
(stubs / "systemctl").write_text(f"#!/bin/sh\necho \"$@\" >> '{sc_calls}'\n")
(stubs / "pactl").write_text(f"#!/bin/sh\n[ \"$1\" = get-default-sink ] && echo '{default_sink}'\n") (stubs / "pactl").write_text(f"#!/bin/sh\n[ \"$1\" = get-default-sink ] && echo '{default_sink}'\n")
for s in stubs.iterdir(): for s in stubs.iterdir():
s.chmod(0o755) s.chmod(0o755)
...@@ -314,3 +316,26 @@ def test_no_ardour_tracks_means_the_mics_are_left_alone_too(tmp_path): ...@@ -314,3 +316,26 @@ def test_no_ardour_tracks_means_the_mics_are_left_alone_too(tmp_path):
inputs = f"ardour:MIDI Control In\n{SINK}:playback_FL\n" inputs = f"ardour:MIDI Control In\n{SINK}:playback_FL\n"
calls, _ = _reconcile(tmp_path, CTRL_LINKED + MICS_LINKED, inputs=inputs) calls, _ = _reconcile(tmp_path, CTRL_LINKED + MICS_LINKED, inputs=inputs)
assert not [c for c in calls if c.startswith("-d")] assert not [c for c in calls if c.startswith("-d")]
def _systemctl_calls(tmp_path):
f = tmp_path / "systemctl.calls"
return f.read_text().splitlines() if f.exists() else []
def test_moving_master_repoints_the_black_box(tmp_path):
"""The recorder resolves its sink once, at start. Master moved, so without this it
would keep recording the OLD sink's monitor: silence, reported as RUNNING."""
_reconcile(tmp_path, CTRL_LINKED + ORBIT_1_LINKED + _master_on(HDMI),
inputs=_inputs_for(HDMI, JACK), default_sink=JACK, state=HDMI)
assert "--user try-restart gig-record.service" in _systemctl_calls(tmp_path)
def test_the_black_box_is_only_restarted_when_master_actually_moved(tmp_path):
_reconcile(tmp_path, CTRL_LINKED + ORBIT_1_LINKED + _master_on(HDMI),
inputs=_inputs_for(HDMI), default_sink=HDMI, state=HDMI)
assert _systemctl_calls(tmp_path) == []
_reconcile(tmp_path, CTRL_LINKED + ORBIT_1_LINKED + _master_on(HDMI, JACK),
inputs=_inputs_for(HDMI, JACK), default_sink=JACK, state=HDMI) # custom: hands off
assert _systemctl_calls(tmp_path) == []
...@@ -200,6 +200,12 @@ reconcile_master() { # $1 = the `pw-link -lo` snapshot ...@@ -200,6 +200,12 @@ reconcile_master() { # $1 = the `pw-link -lo` snapshot
remember_master_sink "$def" remember_master_sink "$def"
note_master "moved" "Master followed the default output: ${sinks##*.} -> ${def##*.}" note_master "moved" "Master followed the default output: ${sinks##*.} -> ${def##*.}"
MASTER_STATE="following" MASTER_STATE="following"
# The black box resolves the sink it listens to ONCE, at start. Master has just
# moved, so left alone it would keep recording the OLD sink's monitor: silence,
# while reporting RUNNING. try-restart only re-points a recorder that is already
# running (it never starts one), at the cost of a new segment file.
systemctl --user try-restart gig-record.service 2>/dev/null \
&& echo "tidal-ardour-autoroute: re-pointed the black box at the new sink"
fi fi
else else
note_master "custom" "Master feeds ${sinks##*.}, not the default: custom wiring, leaving it alone" note_master "custom" "Master feeds ${sinks##*.}, not the default: custom wiring, leaving it alone"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment