Completed player
This commit is contained in:
@@ -11,7 +11,7 @@ with open("config.yaml", "r") as f:
|
||||
|
||||
zones = config.get("zones", {})
|
||||
sources = config.get("sources", {})
|
||||
DEFAULT_SOURCE = "worship"
|
||||
DEFAULT_SOURCE = "Worship"
|
||||
|
||||
print("Zones loaded:", zones.keys())
|
||||
print("Sources loaded:", sources.keys())
|
||||
@@ -73,7 +73,38 @@ def on_connect(client, userdata, flags, rc):
|
||||
client.subscribe(topic)
|
||||
print(f"subscribed to {topic}")
|
||||
|
||||
time.sleep(1)
|
||||
def get_required_jack_ports():
|
||||
required = []
|
||||
|
||||
# From sources
|
||||
for source_name, source_data in sources.items():
|
||||
if source_data.get("active", True):
|
||||
required.append(source_data["left"])
|
||||
required.append(source_data["right"])
|
||||
|
||||
# From zones
|
||||
for zone_name, zone_data in zones.items():
|
||||
if zone_data.get("active", True):
|
||||
required.append(zone_data["left"])
|
||||
required.append(zone_data["right"])
|
||||
|
||||
return required
|
||||
|
||||
def wait_for_required_jack_ports(required_ports, interval=5):
|
||||
print("[router] Waiting for all required JACK ports to appear...")
|
||||
while True:
|
||||
available = set(p.name for p in client_jack.get_ports())
|
||||
missing = [p for p in required_ports if p not in available]
|
||||
if not missing:
|
||||
print("[router] All required JACK ports found. Proceeding.")
|
||||
return
|
||||
print(f"[router] Still waiting for: {missing}")
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
required_ports = get_required_jack_ports()
|
||||
wait_for_required_jack_ports(required_ports)
|
||||
|
||||
active_zones = wait_for_available_zone_ports()
|
||||
apply_default_connections(active_zones)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user