-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open input blocks and never completed #92
Comments
Opening a device (either via ktmidi or Android MIDI API directly) involves Service connection that most likely involves main thread (it might depend on how Android MIDI service is implemented, but anything that involves Service usually does), and you are most likely blocking the main thread. If you try to invoke |
If I do it in another thread then simply no connection is established until the cable is removed. I only switched to main thread to see what's going on. |
If you are trying to connect to a MIDI device that needs permission, you are supposed to provide enough permission (manage permission requests and approvals). When we just deal with MIDI inputs, there is no required permission in MIDI API itself, like this app does not need any: https://github.com/atsushieno/resident-midi-keyboard/blob/main/app/src/main/AndroidManifest.xml |
This got changed in new android versions. You now need to grant permission
via pop up for each USB device to initiate data transfer.
Other apps like Midi connector ble also don't work on newer phones for that
reason.
I am trying to grant the permission and see if it works then
Atsushi Eno ***@***.***> schrieb am Do., 31. Okt. 2024, 08:09:
… If you are trying to connect to a MIDI device that needs permission, you
are supposed to provide enough permission (manage permission requests and
approvals).
When we just deal with MIDI inputs, there is no required permission in
MIDI API itself, like this app does not need any:
https://github.com/atsushieno/resident-midi-keyboard/blob/main/app/src/main/AndroidManifest.xml
—
Reply to this email directly, view it on GitHub
<#92 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOYCLP3V72DRSYWK3ITG47LZ6HJQ3AVCNFSM6AAAAABQZ35UQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBZGE3TEOBUG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes, please let me know if it works or not. I would make sure that you are not trying to block the main thread while you are trying to (indirectly) show the permission approval dialog, as (IF that's still the case) the permission dialog also needs the main thread. |
Hm I tried everything, opening from CoroutineScope and only until permission is granted for the device like so
Still same behavior: Only if cable is removed, the receiver is connected. |
Without any code I can examine, I can at best suggest some tips to debug your app issue: run it on Android Studio in debugging mode, then interrupt (break) while you are waiting for the |
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.
The text was updated successfully, but these errors were encountered: