From f0f5cd3258f718e168c478899cb1e3a39a53345d Mon Sep 17 00:00:00 2001 From: Houston4444 Date: Sat, 29 Nov 2025 16:20:24 +0100 Subject: [PATCH] Create UnknownPort class, which can be created by _wrap_port_ptr if port is nor AUDIO nor MIDI, also add the 'type' property to Port (inherited by UnknownPort) to get the type str of the port --- src/jack.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/jack.py b/src/jack.py index 52e86b4..74d2d2e 100644 --- a/src/jack.py +++ b/src/jack.py @@ -1793,7 +1793,7 @@ def _wrap_port_ptr(self, ptr): elif porttype == _MIDI: cls = OwnMidiPort if self.owns(ptr) else MidiPort else: - assert False + cls = UnknownPort return cls(ptr, self) @@ -1896,6 +1896,11 @@ def unset_alias(self, alias): _check(_lib.jack_port_unset_alias(self._ptr, alias.encode()), 'Error unsetting port alias') + @property + def type(self): + """Name of the JACK port type (read-only).""" + return _decode(_lib.jack_port_type(self._ptr)) + @property def uuid(self): """The UUID of the JACK port.""" @@ -1972,6 +1977,17 @@ class MidiPort(Port): is_midi = property(lambda self: True, doc='This is always ``True``.') +class UnknownPort(Port): + """A JACK port with an unknown type + + This class is derived from `Port` and has exactly the same + attributes and methods. + """ + + is_audio = property(lambda self: False, doc='This is always ``False``.') + is_midi = property(lambda self: False, doc='This is always ``False``.') + + class OwnPort(Port): """A JACK audio port owned by a `Client`.