Skip to content

Commit

Permalink
libmidi_io: backends: alsamidi: Import stripped down version of _find…
Browse files Browse the repository at this point in the history
…_port()

Change-Id: I6b386bbdc5856224a0ab8771ee1ea6b22cf5eab1
  • Loading branch information
SebaUbuntu committed Oct 1, 2022
1 parent 8363c1f commit 7f5926e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libmidi_io/backends/alsamidi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@
#
"""MIDI I/O ALSA MIDI backend."""

from alsa_midi import MidiBytesEvent, PortCaps, PortType, SequencerClient
from alsa_midi.mido_backend import _find_port
from alsa_midi import MidiBytesEvent, PortCaps, PortInfo, PortType, SequencerClient
from libmidi.types.message import message_from_bytes
from libmidi.types.messages.common import BaseMessage
from threading import Thread
from typing import List
from weakref import WeakValueDictionary

from libmidi_io.types.device import Device
from libmidi_io.types.port import BasePort

def _find_port(ports: List[PortInfo], name: str) -> PortInfo:
for port in ports:
libmidi_name = f"{port.client_name}:{port.name} {port.client_id}:{port.port_id}"
if name != libmidi_name:
continue

return port

raise IOError(f"Unknown port {name}")

class _Client:
instance: '_Client' = None

Expand Down

0 comments on commit 7f5926e

Please sign in to comment.