rtmidi-python icon indicating copy to clipboard operation
rtmidi-python copied to clipboard

Crash if USB MIDI device is unplugged

Open josephernest opened this issue 9 years ago • 0 comments

  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

josephernest avatar May 05 '15 20:05 josephernest