Merge "policy_hal: Fix pop noise when MO call is started, while playing music"
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 858a00e..040b140 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -77,6 +77,7 @@
#define WAIT_TIME_SPKR_CALIB (60 * 1000 * 1000)
#define MIN_SPKR_IDLE_SEC (60 * 30)
+#define WAKEUP_MIN_IDLE_CHECK 30
/*Once calibration is started sleep for 1 sec to allow
the calibration to kick off*/
@@ -554,7 +555,7 @@
}
break;
} else if (status.status == -EAGAIN) {
- ALOGD("%s: spkr_prot_thread try again", __func__);
+ ALOGV("%s: spkr_prot_thread try again", __func__);
usleep(WAIT_FOR_GET_CALIB_STATUS);
} else {
ALOGE("%s: spkr_prot_thread get failed status %d",
@@ -734,18 +735,22 @@
if (is_speaker_in_use(&sec)) {
ALOGV("%s: WSA Speaker in use retry calibration", __func__);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
} else {
+ ALOGD("%s: wsa speaker idle %ld,minimum time %ld", __func__, sec, min_idle_time);
if (sec < min_idle_time) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
- ALOGV("%s: wsa speaker idle %ld min time %ld", __func__, sec, min_idle_time);
goahead = true;
}
if (!list_empty(&adev->usecase_list)) {
ALOGD("%s: Usecase active re-try calibration", __func__);
- goahead = false;
+ pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
+ continue;
}
if (goahead) {
if (spk_1_tzn > 0) {
@@ -777,15 +782,17 @@
if (t0_spk_1 < TZ_TEMP_MIN_THRESHOLD ||
t0_spk_1 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
+ ALOGD("%s: temp T0 for spkr1 %d\n", __func__, t0_spk_1);
/*Convert temp into q6 format*/
t0_spk_1 = (t0_spk_1 * (1 << 6));
- ALOGD("%s: temp T0 for spkr1 %d\n", __func__, t0_spk_1);
} else {
ALOGV("%s: thermal equilibrium failed for spkr1 in %d/%d readings\n",
__func__, i, NUM_ATTEMPTS);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
}
@@ -817,15 +824,17 @@
if (t0_spk_2 < TZ_TEMP_MIN_THRESHOLD ||
t0_spk_2 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
+ ALOGD("%s: temp T0 for spkr2 %d\n", __func__, t0_spk_2);
/*Convert temp into q6 format*/
t0_spk_2 = (t0_spk_2 * (1 << 6));
- ALOGD("%s: temp T0 for spkr2 %d\n", __func__, t0_spk_2);
} else {
ALOGV("%s: thermal equilibrium failed for spkr2 in %d/%d readings\n",
__func__, i, NUM_ATTEMPTS);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
}
@@ -859,19 +868,22 @@
if (is_speaker_in_use(&sec)) {
ALOGV("%s: Speaker in use retry calibration", __func__);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
} else {
if (sec < min_idle_time) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
- ALOGD("%s: speaker idle %ld min time %ld", __func__, sec, min_idle_time);
goahead = true;
}
if (!list_empty(&adev->usecase_list)) {
ALOGD("%s: Usecase active re-try calibration", __func__);
goahead = false;
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
+ continue;
}
if (goahead) {
int status;
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index a5d7c29..6d32d2b 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -600,7 +600,7 @@
/// Opens: can these line be executed after the switch of volume curves???
// if leaving call state, handle special case of active streams
// pertaining to sonification strategy see handleIncallSonification()
- if (isInCall()) {
+ if (isStateInCall(oldState)) {
ALOGV("setPhoneState() in call state management: new state is %d", state);
for (size_t j = 0; j < mOutputs.size(); j++) {
audio_io_handle_t curOutput = mOutputs.keyAt(j);