Skip to content

Crash if USB MIDI device is unplugged #19

@josephernest

Description

@josephernest
  1. Connect a USB MIDI IN device (example: USB MIDI keyboard)

  2. Run the following code (see below)

  3. Unplug the USB MIDI IN device

  4. Crash ! or panic (dmesg -wH shows lots of [+0.000167] usb 1-1.4: urb status -32 ... this doesn't seem to happen when rtmidi_midi is not running)

Is there a way to have no crash if a midi device is not available anymore (for example because the device is disconnected) ?


import time
import rtmidi_python as rtmidi

midi_in = rtmidi.MidiIn()
port = midi_in.ports[1]            # this is Akai LPK25  on my system
midi_in.open_port(port)
print 'Opened MIDI: ' + port

i = 0
while True:
 i += 1
 time.sleep(0.5)                           
 print i                                       # a useful loop just to see when exactly it crashes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions