[automerge] audio: SpatializerHelper: fix exceptions when head tracking is not supported 2p: 511336f1b9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17238104 Bug: 224623509 Change-Id: I0406c2f15c625130922e02e1111f2ad78f0ac7b7 Merged-In: I3be6b3f05c9542404379a07f4fc734e45a75152a
This commit is contained in:
@@ -90,6 +90,7 @@ public class SpatializerHelper {
|
|||||||
private @Nullable SpatializerCallback mSpatCallback;
|
private @Nullable SpatializerCallback mSpatCallback;
|
||||||
private @Nullable SpatializerHeadTrackingCallback mSpatHeadTrackingCallback;
|
private @Nullable SpatializerHeadTrackingCallback mSpatHeadTrackingCallback;
|
||||||
private @Nullable HelperDynamicSensorCallback mDynSensorCallback;
|
private @Nullable HelperDynamicSensorCallback mDynSensorCallback;
|
||||||
|
private boolean mIsHeadTrackingSupported = false;
|
||||||
|
|
||||||
// default attributes and format that determine basic availability of spatialization
|
// default attributes and format that determine basic availability of spatialization
|
||||||
private static final AudioAttributes DEFAULT_ATTRIBUTES = new AudioAttributes.Builder()
|
private static final AudioAttributes DEFAULT_ATTRIBUTES = new AudioAttributes.Builder()
|
||||||
@@ -497,8 +498,9 @@ public class SpatializerHelper {
|
|||||||
mSpat = AudioSystem.getSpatializer(mSpatCallback);
|
mSpat = AudioSystem.getSpatializer(mSpatCallback);
|
||||||
try {
|
try {
|
||||||
mSpat.setLevel((byte) Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL);
|
mSpat.setLevel((byte) Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL);
|
||||||
|
mIsHeadTrackingSupported = mSpat.isHeadTrackingSupported();
|
||||||
//TODO: register heatracking callback only when sensors are registered
|
//TODO: register heatracking callback only when sensors are registered
|
||||||
if (mSpat.isHeadTrackingSupported()) {
|
if (mIsHeadTrackingSupported) {
|
||||||
mSpat.registerHeadTrackingCallback(mSpatHeadTrackingCallback);
|
mSpat.registerHeadTrackingCallback(mSpatHeadTrackingCallback);
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -516,11 +518,14 @@ public class SpatializerHelper {
|
|||||||
if (mSpat != null) {
|
if (mSpat != null) {
|
||||||
mSpatCallback = null;
|
mSpatCallback = null;
|
||||||
try {
|
try {
|
||||||
mSpat.registerHeadTrackingCallback(null);
|
if (mIsHeadTrackingSupported) {
|
||||||
|
mSpat.registerHeadTrackingCallback(null);
|
||||||
|
}
|
||||||
mSpat.release();
|
mSpat.release();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Can't set release spatializer cleanly", e);
|
Log.e(TAG, "Can't set release spatializer cleanly", e);
|
||||||
}
|
}
|
||||||
|
mIsHeadTrackingSupported = false;
|
||||||
mSpat = null;
|
mSpat = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,7 +692,6 @@ public class SpatializerHelper {
|
|||||||
mDesiredHeadTrackingMode = mode;
|
mDesiredHeadTrackingMode = mode;
|
||||||
dispatchDesiredHeadTrackingMode(mode);
|
dispatchDesiredHeadTrackingMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error calling setDesiredHeadTrackingMode", e);
|
Log.e(TAG, "Error calling setDesiredHeadTrackingMode", e);
|
||||||
}
|
}
|
||||||
@@ -708,7 +712,7 @@ public class SpatializerHelper {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return mIsHeadTrackingSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchActualHeadTrackingMode(int newMode) {
|
private void dispatchActualHeadTrackingMode(int newMode) {
|
||||||
@@ -882,13 +886,8 @@ public class SpatializerHelper {
|
|||||||
Log.e(TAG, "not " + action + " sensors, null spatializer");
|
Log.e(TAG, "not " + action + " sensors, null spatializer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
if (!mIsHeadTrackingSupported) {
|
||||||
if (!mSpat.isHeadTrackingSupported()) {
|
Log.e(TAG, "not " + action + " sensors, spatializer doesn't support headtracking");
|
||||||
Log.e(TAG, "not " + action + " sensors, spatializer doesn't support headtracking");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(TAG, "not " + action + " sensors, error querying headtracking", e);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int headHandle = -1;
|
int headHandle = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user