Skip to content

Commit ff5fbc6

Browse files
authored
Create UnknownPort class, add the 'type' property to Port (#149)
1 parent 6adb95f commit ff5fbc6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/jack.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ def _wrap_port_ptr(self, ptr):
17931793
elif porttype == _MIDI:
17941794
cls = OwnMidiPort if self.owns(ptr) else MidiPort
17951795
else:
1796-
assert False
1796+
cls = UnknownPort
17971797
return cls(ptr, self)
17981798

17991799

@@ -1896,6 +1896,11 @@ def unset_alias(self, alias):
18961896
_check(_lib.jack_port_unset_alias(self._ptr, alias.encode()),
18971897
'Error unsetting port alias')
18981898

1899+
@property
1900+
def type(self):
1901+
"""Name of the JACK port type (read-only)."""
1902+
return _decode(_lib.jack_port_type(self._ptr))
1903+
18991904
@property
19001905
def uuid(self):
19011906
"""The UUID of the JACK port."""
@@ -1972,6 +1977,17 @@ class MidiPort(Port):
19721977
is_midi = property(lambda self: True, doc='This is always ``True``.')
19731978

19741979

1980+
class UnknownPort(Port):
1981+
"""A JACK port with an unknown type
1982+
1983+
This class is derived from `Port` and has exactly the same
1984+
attributes and methods.
1985+
"""
1986+
1987+
is_audio = property(lambda self: False, doc='This is always ``False``.')
1988+
is_midi = property(lambda self: False, doc='This is always ``False``.')
1989+
1990+
19751991
class OwnPort(Port):
19761992
"""A JACK audio port owned by a `Client`.
19771993

0 commit comments

Comments
 (0)