AudioService: fix initial spatial audio enable state.

Fix SpatializerHelper.setSpatializerEnabledInt() to
avoid overriding the enable state computed by onRoutingUpdated()
when spatial audio is enabled.

Bug: 238378679
Test: repro steps in the bug
Merged-In: I2e77945c889c1db093832f780c632a626e979e7c
Change-Id: I2e77945c889c1db093832f780c632a626e979e7c
This commit is contained in:
Eric Laurent 2022-08-02 16:12:36 +02:00 committed by Andy Hung
parent a36a023dae
commit 5b78fb7069

View File

@ -745,33 +745,29 @@ public class SpatializerHelper {
if (enabled) {
throw (new IllegalStateException("Can't enable when uninitialized"));
}
return;
break;
case STATE_NOT_SUPPORTED:
if (enabled) {
Log.e(TAG, "Can't enable when unsupported");
}
return;
break;
case STATE_DISABLED_UNAVAILABLE:
case STATE_DISABLED_AVAILABLE:
if (enabled) {
createSpat();
onRoutingUpdated();
break;
} else {
// already in disabled state
return;
}
// onRoutingUpdated() can update the "enabled" state based on context
// and will call setDispatchFeatureEnabledState().
} // else { nothing to do as already disabled }
break;
case STATE_ENABLED_UNAVAILABLE:
case STATE_ENABLED_AVAILABLE:
if (!enabled) {
releaseSpat();
break;
} else {
// already in enabled state
return;
}
setDispatchFeatureEnabledState(false, "setSpatializerEnabledInt");
} // else { nothing to do as already enabled }
break;
}
setDispatchFeatureEnabledState(enabled, "setSpatializerEnabledInt");
}
synchronized int getCapableImmersiveAudioLevel() {