audiopolicy: apm: Fix segfault when using bus device without Policy Mix
Test: manual audio smoke tests
Change-Id: Ic9ecd5928931d63d42cecea7283c7282ec43ebc0
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index d7cf88e..30b438d 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -4271,12 +4271,13 @@
addOutput(output, desc);
if (device_distinguishes_on_address(deviceType) && address != "0") {
sp<AudioPolicyMix> policyMix;
- if (mPolicyMixes.getAudioPolicyMix(address, policyMix) != NO_ERROR) {
- ALOGE("checkOutputsForDevice() cannot find policy for address %s",
+ if (mPolicyMixes.getAudioPolicyMix(address, policyMix) == NO_ERROR) {
+ policyMix->setOutput(desc);
+ desc->mPolicyMix = policyMix->getMix();
+ } else {
+ ALOGW("checkOutputsForDevice() cannot find policy for address %s",
address.string());
}
- policyMix->setOutput(desc);
- desc->mPolicyMix = policyMix->getMix();
} else if (((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) &&
hasPrimaryOutput()) {