Skip to content

Commit c261664

Browse files
committed
Add optional argument to OwnPort.disconnect()
1 parent e96b27f commit c261664

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

‎jack.py‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,10 +1464,25 @@ def connect(self, port):
14641464
assert False
14651465
self._client.connect(source.name, destination.name)
14661466

1467-
def disconnect(self):
1468-
"""Disconnect all connections of this port."""
1469-
_check(_lib.jack_port_disconnect(self._client._ptr, self._ptr),
1470-
"Error disconnecting {0!r}".format(self.name))
1467+
def disconnect(self, other=None):
1468+
"""Disconnect this port.
1469+
1470+
Parameters
1471+
----------
1472+
other : str or Port
1473+
Port to disconnect from.
1474+
By default, disconnect from all connected ports.
1475+
1476+
"""
1477+
if other is None:
1478+
_check(_lib.jack_port_disconnect(self._client._ptr, self._ptr),
1479+
"Error disconnecting {0!r}".format(self.name))
1480+
else:
1481+
if self.is_output:
1482+
args = self, other
1483+
elif self.is_input:
1484+
args = other, self
1485+
self._client.disconnect(*args)
14711486

14721487
def unregister(self):
14731488
"""Unregister port.

0 commit comments

Comments
 (0)