summaryrefslogtreecommitdiff
path: root/media/packages
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2017-04-14 12:15:56 -0700
committerPhil Burk <philburk@google.com>2017-04-14 14:16:39 -0700
commit1f99a3277ba39f65195b953c6f82fc323d925850 (patch)
tree2edba0cfca880ffc036fa9acf5230654fda3e5e8 /media/packages
parent3a543a1bd2876e1d9b7da706e55594f589d16ec1 (diff)
BluetoothMidi: request higher priority, for lower latency
Request a higher connection priority. This will result in a Connection Interval below 15 msec vs 45 msec for some devices. Fix: 34710538 Test: Connect a BLE-MIDI device using the MIDI+BTLE test app. See bug. Change-Id: I846a76a36c864f82969173a94d86b05059a786ad Signed-off-by: Phil Burk <philburk@google.com>
Diffstat (limited to 'media/packages')
-rw-r--r--media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java40
1 files changed, 20 insertions, 20 deletions
diff --git a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
index 444705cfc79f..ece700dc8b6d 100644
--- a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
+++ b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
@@ -100,8 +100,8 @@ public final class BluetoothMidiDevice {
int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
- Log.i(TAG, "Connected to GATT server.");
- Log.i(TAG, "Attempting to start service discovery:" +
+ Log.d(TAG, "Connected to GATT server.");
+ Log.d(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.i(TAG, "Disconnected from GATT server.");
@@ -112,24 +112,24 @@ public final class BluetoothMidiDevice {
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
- List<BluetoothGattService> services = mBluetoothGatt.getServices();
- for (BluetoothGattService service : services) {
- if (MIDI_SERVICE.equals(service.getUuid())) {
- Log.d(TAG, "found MIDI_SERVICE");
- List<BluetoothGattCharacteristic> characteristics
- = service.getCharacteristics();
- for (BluetoothGattCharacteristic characteristic : characteristics) {
- if (MIDI_CHARACTERISTIC.equals(characteristic.getUuid())) {
- Log.d(TAG, "found MIDI_CHARACTERISTIC");
- mCharacteristic = characteristic;
-
- // Specification says to read the characteristic first and then
- // switch to receiving notifications
- mBluetoothGatt.readCharacteristic(characteristic);
- break;
- }
- }
- break;
+ BluetoothGattService service = gatt.getService(MIDI_SERVICE);
+ if (service != null) {
+ Log.d(TAG, "found MIDI_SERVICE");
+ BluetoothGattCharacteristic characteristic
+ = service.getCharacteristic(MIDI_CHARACTERISTIC);
+ if (characteristic != null) {
+ Log.d(TAG, "found MIDI_CHARACTERISTIC");
+ mCharacteristic = characteristic;
+
+ // Request a lower Connection Interval for better latency.
+ boolean result = gatt.requestConnectionPriority(
+ BluetoothGatt.CONNECTION_PRIORITY_HIGH);
+ Log.d(TAG, "requestConnectionPriority(CONNECTION_PRIORITY_HIGH):"
+ + result);
+
+ // Specification says to read the characteristic first and then
+ // switch to receiving notifications
+ mBluetoothGatt.readCharacteristic(characteristic);
}
}
} else {