audio policy: fix camera shutter sound

Fix regression in camera shutter sound when system stream
volume is 0.

Bug: 132696227
Test: repro steps in bug.
Test: regressions when camera sound is enforced
Change-Id: I76b4a5ee041f97c5f771c003bf4f99327d797096
gugelfrei
Eric Laurent 5 years ago
parent 4fc900d756
commit 22fcda29e5

@ -70,20 +70,7 @@ product_strategy_t EngineBase::getProductStrategyForAttributes(const audio_attri
audio_stream_type_t EngineBase::getStreamTypeForAttributes(const audio_attributes_t &attr) const
{
audio_stream_type_t engineStream = mProductStrategies.getStreamTypeForAttributes(attr);
// ensure the audibility flag for sonification is honored for stream types
// Note this is typically implemented in the product strategy configuration files, but is
// duplicated here for safety.
if (attr.usage == AUDIO_USAGE_ASSISTANCE_SONIFICATION
&& ((attr.flags & AUDIO_FLAG_AUDIBILITY_ENFORCED) != 0)) {
engineStream = AUDIO_STREAM_ENFORCED_AUDIBLE;
}
// ensure the ENFORCED_AUDIBLE stream type reflects the "force use" setting:
if ((getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) != AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)
&& (engineStream == AUDIO_STREAM_ENFORCED_AUDIBLE)) {
return AUDIO_STREAM_SYSTEM;
}
return engineStream;
return mProductStrategies.getStreamTypeForAttributes(attr);
}
audio_attributes_t EngineBase::getAttributesForStreamType(audio_stream_type_t stream) const

@ -777,6 +777,12 @@ void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
// check for device and output changes triggered by new force usage
checkForDeviceAndOutputChanges();
// force client reconnection to reevaluate flag AUDIO_FLAG_AUDIBILITY_ENFORCED
if (usage == AUDIO_POLICY_FORCE_FOR_SYSTEM) {
mpClientInterface->invalidateStream(AUDIO_STREAM_SYSTEM);
mpClientInterface->invalidateStream(AUDIO_STREAM_ENFORCED_AUDIBLE);
}
//FIXME: workaround for truncated touch sounds
// to be removed when the problem is handled by system UI
uint32_t delayMs = 0;
@ -910,6 +916,13 @@ status_t AudioPolicyManager::getAudioAttributes(audio_attributes_t *dstAttr,
}
*dstAttr = mEngine->getAttributesForStreamType(srcStream);
}
// Only honor audibility enforced when required. The client will be
// forced to reconnect if the forced usage changes.
if (mEngine->getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) != AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) {
dstAttr->flags &= ~AUDIO_FLAG_AUDIBILITY_ENFORCED;
}
return NO_ERROR;
}

Loading…
Cancel
Save