Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Add hardware reconnection maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Apr 26, 2018
1 parent 6082097 commit c69928a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object MidiHandler : Disposable {
while (midiDevice == null && deviceInfo.hasNext()) {
try {
val possibleDevice = MidiSystem.getMidiDevice(deviceInfo.next())
if (possibleDevice !is Synthesizer && possibleDevice !is Sequencer) {
if (possibleDevice !is Synthesizer && possibleDevice !is Sequencer && possibleDevice.maxTransmitters != 0) {
this.midiDevice = possibleDevice
possibleDevice.open()
possibleDevice.transmitter.receiver = MidiReceiver(possibleDevice)
Expand All @@ -42,8 +42,13 @@ object MidiHandler : Disposable {
}
} catch (e: MidiUnavailableException) {
// Ignored
e.printStackTrace()
}
}
} else if (!device.isOpen) {
(device.transmitter.receiver as? MidiReceiver)?.close()
this.midiDevice?.close()
this.midiDevice = null
}
}
}
Expand Down

0 comments on commit c69928a

Please sign in to comment.