]> git.0d.be Git - django-panik-nonstop.git/blobdiff - nonstop/management/commands/switch-jack.py
switch-jack: allow for multiple outputs
[django-panik-nonstop.git] / nonstop / management / commands / switch-jack.py
index 121823b6503fbc41495fbd9601bdfbc4f9bdd083..7e8b8c5a4d092fa4e783d144d6fb7e3e61464062 100644 (file)
@@ -60,25 +60,26 @@ class Command(BaseCommand):
             logger.info('unsupported source: %s', active)
             return
         logger.info('setting source: %s', active)
-        dports = app_settings.SWITCH_OUT_PORTS
+        out_ports = app_settings.SWITCH_OUT_PORTS
         with jack.Client('switch-jack') as client:
             known_ports = {x.name for x in client.get_ports(is_audio=True)}
-            if any(x not in known_ports for x in dports):
-                logger.error('unavailable destination ports %r', dports)
-                return
-            for port_id, port_names in app_settings.SWITCH_IN_PORTS.items():
-                if any(x not in known_ports for x in port_names):
-                    logger.error('unavailable source ports %r', port_names)
+            for dports in out_ports.values():
+                if any(x not in known_ports for x in dports):
+                    logger.error('unavailable destination ports %r', dports)
                     continue
-                try:
-                    if port_id == active:
-                        self.jack_connect(client, port_names[0], dports[0])
-                        self.jack_connect(client, port_names[1], dports[1])
-                    else:
-                        self.jack_disconnect(client, port_names[0], dports[0])
-                        self.jack_disconnect(client, port_names[1], dports[1])
-                except jack.JackError as e:
-                    logger.error('jack error: %s' % e)
+                for port_id, port_names in app_settings.SWITCH_IN_PORTS.items():
+                    if any(x not in known_ports for x in port_names):
+                        logger.error('unavailable source ports %r', port_names)
+                        continue
+                    try:
+                        if port_id == active:
+                            self.jack_connect(client, port_names[0], dports[0])
+                            self.jack_connect(client, port_names[1], dports[1])
+                        else:
+                            self.jack_disconnect(client, port_names[0], dports[0])
+                            self.jack_disconnect(client, port_names[1], dports[1])
+                    except jack.JackError as e:
+                        logger.error('jack error: %s' % e)
 
     def jack_connect(self, client, in_port, out_port):
         connections = [x.name for x in client.get_all_connections(in_port)]