policy_hal: handle incall sonification without checking output refCount
Call handleIncallSonification in startSource and stopSource without
checking mRefCount to make sure ringtone mute/unmute is called for
multiple active stream.
Change-Id: I52290f9ae09dff3619ac3a36c8969da6c07853ec
CRs-Fixed: 972582
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 37cceab..cbebf42 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* Not a contribution.
*
* Copyright (C) 2009 The Android Open Source Project
@@ -397,6 +397,7 @@
ALOGW("setDeviceConnectionState() invalid device: %x", device);
return BAD_VALUE;
}
+
// This function checks for the parameters which can be offloaded.
// This can be enhanced depending on the capability of the DSP and policy
// of the system.
@@ -577,6 +578,7 @@
ALOGV("isOffloadSupported() profile %sfound", profile != 0 ? "" : "NOT ");
return (profile != 0);
}
+
audio_devices_t AudioPolicyManagerCustom::getNewOutputDevice(const sp<AudioOutputDescriptor>& outputDesc,
bool fromCache)
{
@@ -642,6 +644,7 @@
ALOGV("getNewOutputDevice() selected device %x", device);
return device;
}
+
void AudioPolicyManagerCustom::setPhoneState(audio_mode_t state)
{
ALOGV("setPhoneState() state %d", state);
@@ -1013,7 +1016,7 @@
handleEventForBeacon(stream == AUDIO_STREAM_TTS ? STOPPING_BEACON : STOPPING_OUTPUT);
// handle special case for sonification while in call
- if (isInCall() && (outputDesc->mRefCount[stream] == 1)) {
+ if (isInCall()) {
if (outputDesc->isDuplicated()) {
handleIncallSonification(stream, false, false, outputDesc->subOutput1()->mIoHandle);
handleIncallSonification(stream, false, false, outputDesc->subOutput2()->mIoHandle);
@@ -1068,6 +1071,7 @@
return INVALID_OPERATION;
}
}
+
status_t AudioPolicyManagerCustom::startSource(sp<AudioOutputDescriptor> outputDesc,
audio_stream_type_t stream,
audio_devices_t device,
@@ -1153,13 +1157,14 @@
}
}
else {
- // handle special case for sonification while in call
- if (isInCall()) {
- handleIncallSonification(stream, true, false, outputDesc->mIoHandle);
- }
+ // handle special case for sonification while in call
+ if (isInCall()) {
+ handleIncallSonification(stream, true, false, outputDesc->mIoHandle);
}
+ }
return NO_ERROR;
}
+
void AudioPolicyManagerCustom::handleIncallSonification(audio_stream_type_t stream,
bool starting, bool stateChange,
audio_io_handle_t output)
@@ -1212,6 +1217,7 @@
}
}
}
+
void AudioPolicyManagerCustom::handleNotificationRoutingForStream(audio_stream_type_t stream) {
switch(stream) {
case AUDIO_STREAM_MUSIC:
@@ -1222,6 +1228,7 @@
break;
}
}
+
status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream,
int index,
const sp<AudioOutputDescriptor>& outputDesc,
@@ -1291,6 +1298,7 @@
return NO_ERROR;
}
+
bool AudioPolicyManagerCustom::isDirectOutput(audio_io_handle_t output) {
for (size_t i = 0; i < mOutputs.size(); i++) {
audio_io_handle_t curOutput = mOutputs.keyAt(i);
@@ -1861,6 +1869,7 @@
selectedDeviceId,
inputType);
}
+
status_t AudioPolicyManagerCustom::startInput(audio_io_handle_t input,
audio_session_t session)
{
@@ -1984,6 +1993,7 @@
#endif
return NO_ERROR;
}
+
status_t AudioPolicyManagerCustom::stopInput(audio_io_handle_t input,
audio_session_t session)
{