I try to receive messages from a connected usb MIDI device.
val midiAccess = AndroidMidiAccess(this)
val midiInput = runBlocking {
midiAccess.openInput(midiAccess.inputs.first().id)
}
midiInput.setMessageReceivedListener(this@MainActivity)
However, the app becomes unresponsive whenever calling openInput, indicating that no input can be established. This happens on google pixel 7 (android-version 14). The code only continues (setting listener) as soon as I unplug the Midi cable again.
I know this is caused by runBlocking and this only helps to make clear that no input can be established.
I noticed this did not happen on my older Samsung galaxy S9 (same code).
After some digging I found that the issue is this line in the MidiDevice.java file:
FileDescriptor fd = mDeviceServer.openInputPort(token, portNumber);
Somehow calling openInputPort on the IMidiDeviceServer blocks until the cable is removed again.
I try to receive messages from a connected usb MIDI device.
However, the app becomes unresponsive whenever calling openInput, indicating that no input can be established. This happens on google pixel 7 (android-version 14). The code only continues (setting listener) as soon as I unplug the Midi cable again.
I know this is caused by runBlocking and this only helps to make clear that no input can be established.
I noticed this did not happen on my older Samsung galaxy S9 (same code).
After some digging I found that the issue is this line in the MidiDevice.java file:
FileDescriptor fd = mDeviceServer.openInputPort(token, portNumber);Somehow calling openInputPort on the IMidiDeviceServer blocks until the cable is removed again.