We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
ご参考にしていただけましたら。
つまり、詰まっている場合の処理を変更しました。 パケット数に制限をつけることで、遅延こそあれ、ロストが起きなくしました。
MidiOutputDevice.java ``
final Thread transferDataThread = new Thread(new Runnable() { @Override public void run() { transferDataThreadAlive = true; ByteArrayOutputStream stream = new ByteArrayOutputStream(); while (transferDataThreadAlive) { stream.reset(); PacketData packet = _queue.pop(); packet._time = 0; stream.write((byte) (0x80 | ((packet._time >> 7) & 0x3f))); stream.write((byte) (0x80 | (packet._time & 0x7f))); stream.write(packet._data, packet._offset, packet._count); boolean sysex1 = (packet._data[packet._offset] & 0xff) == 0xf0; _packetGenerator.markRecyled(packet); int poped = 1; if (sysex1) { transferData(stream.toByteArray()); } else { while (!_queue.isEmpty()) { packet = _queue.pop(); boolean sysex2 = (packet._data[packet._offset] & 0xff) == 0xf0; if (sysex2) { _queue.back(packet); break; } poped ++; if (poped >= 7) { _queue.back(packet); break; } packet._time = 0; stream.write((byte) (0x80 | (packet._time & 0x7f))); stream.write(packet._data, packet._offset, packet._count); _packetGenerator.markRecyled(packet); packet = null; } transferData(stream.toByteArray()); } if (poped >= 4) { Log.e(TAG, "Poped " + poped); } } } });
``
BleMidiCallback.java
@Override public boolean transferData(@NonNull byte[] writeBuffer) throws SecurityException { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { int result = bluetoothGatt.writeCharacteristic(midiOutputCharacteristic, writeBuffer, BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); if (result == 201) { int retry = 0; do { try { Thread.sleep(20); }catch (InterruptedException ex) { } ++ retry; if (retry >= 2) { Log.e(Constants.TAG, "201 retry " + retry); } if (retry >= 100) { break; } result = bluetoothGatt.writeCharacteristic(midiOutputCharacteristic, writeBuffer, BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); if (result != 0 && result != 201) { Log.e(Constants.TAG, "*** " + result + " retry " + retry); } }while(result == 201); } return result == BluetoothStatusCodes.SUCCESS; } else { midiOutputCharacteristic.setValue(writeBuffer); boolean result = bluetoothGatt.writeCharacteristic(midiOutputCharacteristic); if (result != true) { Log.e(Constants.TAG, "transferData 2 Error "+ result); } return result; } } catch (Throwable ignored) { // android.os.DeadObjectException will be thrown // ignore it return false; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ご参考にしていただけましたら。
つまり、詰まっている場合の処理を変更しました。
パケット数に制限をつけることで、遅延こそあれ、ロストが起きなくしました。
MidiOutputDevice.java
``
``
BleMidiCallback.java
``
``
The text was updated successfully, but these errors were encountered: