Merge "SpatializerHelper: fix null routing" am: dddba4569f am: 262fca259c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2210002 Change-Id: I17cfd8ace3b4164520b1de4a6abfdc116dc6fd59 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1914,7 +1914,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID getDeviceSensorUuid(AudioDeviceAttributes device) {
|
@Nullable UUID getDeviceSensorUuid(AudioDeviceAttributes device) {
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
return mDeviceInventory.getDeviceSensorUuid(device);
|
return mDeviceInventory.getDeviceSensorUuid(device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.android.server.audio;
|
package com.android.server.audio;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
@@ -1498,7 +1499,7 @@ public class AudioDeviceInventory {
|
|||||||
mDevRoleCapturePresetDispatchers.finishBroadcast();
|
mDevRoleCapturePresetDispatchers.finishBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID getDeviceSensorUuid(AudioDeviceAttributes device) {
|
@Nullable UUID getDeviceSensorUuid(AudioDeviceAttributes device) {
|
||||||
final String key = DeviceInfo.makeDeviceListKey(device.getInternalType(),
|
final String key = DeviceInfo.makeDeviceListKey(device.getInternalType(),
|
||||||
device.getAddress());
|
device.getAddress());
|
||||||
synchronized (mDevicesLock) {
|
synchronized (mDevicesLock) {
|
||||||
|
|||||||
@@ -347,6 +347,14 @@ public class SpatializerHelper {
|
|||||||
mASA.getDevicesForAttributes(
|
mASA.getDevicesForAttributes(
|
||||||
DEFAULT_ATTRIBUTES, false /* forVolume */).toArray(ROUTING_DEVICES);
|
DEFAULT_ATTRIBUTES, false /* forVolume */).toArray(ROUTING_DEVICES);
|
||||||
|
|
||||||
|
// check validity of routing information
|
||||||
|
if (ROUTING_DEVICES[0] == null) {
|
||||||
|
logloge("onRoutingUpdated: device is null, no Spatial Audio");
|
||||||
|
setDispatchAvailableState(false);
|
||||||
|
// not changing the spatializer level as this is likely a transient state
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// is media routed to a new device?
|
// is media routed to a new device?
|
||||||
if (isWireless(ROUTING_DEVICES[0].getType())) {
|
if (isWireless(ROUTING_DEVICES[0].getType())) {
|
||||||
addWirelessDeviceIfNew(ROUTING_DEVICES[0]);
|
addWirelessDeviceIfNew(ROUTING_DEVICES[0]);
|
||||||
@@ -1093,7 +1101,7 @@ public class SpatializerHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check current routing to see if it affects the headtracking mode
|
// check current routing to see if it affects the headtracking mode
|
||||||
if (ROUTING_DEVICES[0].getType() == ada.getType()
|
if (ROUTING_DEVICES[0] != null && ROUTING_DEVICES[0].getType() == ada.getType()
|
||||||
&& ROUTING_DEVICES[0].getAddress().equals(ada.getAddress())) {
|
&& ROUTING_DEVICES[0].getAddress().equals(ada.getAddress())) {
|
||||||
setDesiredHeadTrackingMode(enabled ? mDesiredHeadTrackingModeWhenEnabled
|
setDesiredHeadTrackingMode(enabled ? mDesiredHeadTrackingModeWhenEnabled
|
||||||
: Spatializer.HEAD_TRACKING_MODE_DISABLED);
|
: Spatializer.HEAD_TRACKING_MODE_DISABLED);
|
||||||
@@ -1651,7 +1659,11 @@ public class SpatializerHelper {
|
|||||||
|
|
||||||
private int getHeadSensorHandleUpdateTracker() {
|
private int getHeadSensorHandleUpdateTracker() {
|
||||||
int headHandle = -1;
|
int headHandle = -1;
|
||||||
UUID routingDeviceUuid = mAudioService.getDeviceSensorUuid(ROUTING_DEVICES[0]);
|
final AudioDeviceAttributes currentDevice = ROUTING_DEVICES[0];
|
||||||
|
if (currentDevice == null) {
|
||||||
|
return headHandle;
|
||||||
|
}
|
||||||
|
UUID routingDeviceUuid = mAudioService.getDeviceSensorUuid(currentDevice);
|
||||||
// We limit only to Sensor.TYPE_HEAD_TRACKER here to avoid confusion
|
// We limit only to Sensor.TYPE_HEAD_TRACKER here to avoid confusion
|
||||||
// with gaming sensors. (Note that Sensor.TYPE_ROTATION_VECTOR
|
// with gaming sensors. (Note that Sensor.TYPE_ROTATION_VECTOR
|
||||||
// and Sensor.TYPE_GAME_ROTATION_VECTOR are supported internally by
|
// and Sensor.TYPE_GAME_ROTATION_VECTOR are supported internally by
|
||||||
@@ -1662,7 +1674,7 @@ public class SpatializerHelper {
|
|||||||
final UUID uuid = sensor.getUuid();
|
final UUID uuid = sensor.getUuid();
|
||||||
if (uuid.equals(routingDeviceUuid)) {
|
if (uuid.equals(routingDeviceUuid)) {
|
||||||
headHandle = sensor.getHandle();
|
headHandle = sensor.getHandle();
|
||||||
if (!setHasHeadTracker(ROUTING_DEVICES[0])) {
|
if (!setHasHeadTracker(currentDevice)) {
|
||||||
headHandle = -1;
|
headHandle = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user