Merge "AudioService: Fix SpatializerHelper asserts" into tm-qpr-dev
This commit is contained in:
@@ -368,6 +368,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
private static final int MSG_DISPATCH_DEVICE_VOLUME_BEHAVIOR = 47;
|
private static final int MSG_DISPATCH_DEVICE_VOLUME_BEHAVIOR = 47;
|
||||||
private static final int MSG_ROTATION_UPDATE = 48;
|
private static final int MSG_ROTATION_UPDATE = 48;
|
||||||
private static final int MSG_FOLD_UPDATE = 49;
|
private static final int MSG_FOLD_UPDATE = 49;
|
||||||
|
private static final int MSG_RESET_SPATIALIZER = 50;
|
||||||
|
|
||||||
// start of messages handled under wakelock
|
// start of messages handled under wakelock
|
||||||
// these messages can only be queued, i.e. sent with queueMsgUnderWakeLock(),
|
// these messages can only be queued, i.e. sent with queueMsgUnderWakeLock(),
|
||||||
@@ -375,6 +376,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
private static final int MSG_DISABLE_AUDIO_FOR_UID = 100;
|
private static final int MSG_DISABLE_AUDIO_FOR_UID = 100;
|
||||||
private static final int MSG_INIT_STREAMS_VOLUMES = 101;
|
private static final int MSG_INIT_STREAMS_VOLUMES = 101;
|
||||||
private static final int MSG_INIT_SPATIALIZER = 102;
|
private static final int MSG_INIT_SPATIALIZER = 102;
|
||||||
|
|
||||||
// end of messages handled under wakelock
|
// end of messages handled under wakelock
|
||||||
|
|
||||||
// retry delay in case of failure to indicate system ready to AudioFlinger
|
// retry delay in case of failure to indicate system ready to AudioFlinger
|
||||||
@@ -8297,6 +8299,10 @@ public class AudioService extends IAudioService.Stub
|
|||||||
onPersistSpatialAudioDeviceSettings();
|
onPersistSpatialAudioDeviceSettings();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSG_RESET_SPATIALIZER:
|
||||||
|
mSpatializerHelper.reset(/* featureEnabled */ mHasSpatializerEffect);
|
||||||
|
break;
|
||||||
|
|
||||||
case MSG_CHECK_MUSIC_ACTIVE:
|
case MSG_CHECK_MUSIC_ACTIVE:
|
||||||
onCheckMusicActive((String) msg.obj);
|
onCheckMusicActive((String) msg.obj);
|
||||||
break;
|
break;
|
||||||
@@ -9275,6 +9281,16 @@ public class AudioService extends IAudioService.Stub
|
|||||||
/*arg1*/ 0, /*arg2*/ 0, TAG, /*delay*/ 0);
|
/*arg1*/ 0, /*arg2*/ 0, TAG, /*delay*/ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post a message to schedule a reset of the spatializer state
|
||||||
|
*/
|
||||||
|
void postResetSpatializer() {
|
||||||
|
sendMsg(mAudioHandler,
|
||||||
|
MSG_RESET_SPATIALIZER,
|
||||||
|
SENDMSG_REPLACE,
|
||||||
|
/*arg1*/ 0, /*arg2*/ 0, TAG, /*delay*/ 0);
|
||||||
|
}
|
||||||
|
|
||||||
void onInitSpatializer() {
|
void onInitSpatializer() {
|
||||||
final String settings = mSettings.getSecureStringForUser(mContentResolver,
|
final String settings = mSettings.getSecureStringForUser(mContentResolver,
|
||||||
Settings.Secure.SPATIAL_AUDIO_ENABLED, UserHandle.USER_CURRENT);
|
Settings.Secure.SPATIAL_AUDIO_ENABLED, UserHandle.USER_CURRENT);
|
||||||
|
|||||||
@@ -389,10 +389,10 @@ public class SpatializerHelper {
|
|||||||
try {
|
try {
|
||||||
mSpat.setLevel(level);
|
mSpat.setLevel(level);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Can't set spatializer level", e);
|
Log.e(TAG, "onRoutingUpdated() Can't set spatializer level", e);
|
||||||
mState = STATE_NOT_SUPPORTED;
|
// try to recover by resetting the native spatializer state
|
||||||
mCapableSpatLevel = Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE;
|
postReset();
|
||||||
enabled = false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,6 +404,10 @@ public class SpatializerHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void postReset() {
|
||||||
|
mAudioService.postResetSpatializer();
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// spatializer callback from native
|
// spatializer callback from native
|
||||||
private final class SpatializerCallback extends INativeSpatializerCallback.Stub {
|
private final class SpatializerCallback extends INativeSpatializerCallback.Stub {
|
||||||
@@ -1157,8 +1161,11 @@ public class SpatializerHelper {
|
|||||||
case STATE_DISABLED_AVAILABLE:
|
case STATE_DISABLED_AVAILABLE:
|
||||||
case STATE_ENABLED_AVAILABLE:
|
case STATE_ENABLED_AVAILABLE:
|
||||||
if (mSpat == null) {
|
if (mSpat == null) {
|
||||||
throw (new IllegalStateException(
|
// try to recover by resetting the native spatializer state
|
||||||
"null Spatializer when calling " + funcName));
|
Log.e(TAG, "checkSpatForHeadTracking(): "
|
||||||
|
+ "native spatializer should not be null in state: " + mState);
|
||||||
|
postReset();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1248,8 +1255,8 @@ public class SpatializerHelper {
|
|||||||
case STATE_DISABLED_AVAILABLE:
|
case STATE_DISABLED_AVAILABLE:
|
||||||
case STATE_ENABLED_AVAILABLE:
|
case STATE_ENABLED_AVAILABLE:
|
||||||
if (mSpat == null) {
|
if (mSpat == null) {
|
||||||
throw (new IllegalStateException(
|
Log.e(TAG, "setParameter(" + key + "): null spatializer in state: " + mState);
|
||||||
"null Spatializer for setParameter for key:" + key));
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1272,8 +1279,8 @@ public class SpatializerHelper {
|
|||||||
case STATE_DISABLED_AVAILABLE:
|
case STATE_DISABLED_AVAILABLE:
|
||||||
case STATE_ENABLED_AVAILABLE:
|
case STATE_ENABLED_AVAILABLE:
|
||||||
if (mSpat == null) {
|
if (mSpat == null) {
|
||||||
throw (new IllegalStateException(
|
Log.e(TAG, "getParameter(" + key + "): null spatializer in state: " + mState);
|
||||||
"null Spatializer for getParameter for key:" + key));
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user