hal: end all calls when setmode(AUDIO_MODE_NORMAL) is called
Telephony will call set_mode(AUDIO_MODE_NORMAL) when a
call is ended which will trigger audio policy manager setting
routing with audio usecase compatible device. Voice calls can
still be active if RIL has not yet called
setparameters(vsid,callstate). This would result in routing
voice call usecases with incompatible device for voice calls.
Fix this by ending all voice calls when set_mode(MODE_NORMAL)
is called.
Change-Id: Id2c9f2ff9ed46969e5cbd27b525b81735c1d49d8
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 64db646..7d438ba 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -98,7 +98,7 @@
.format = PCM_FORMAT_S16_LE,
};
-static const char * const use_case_table[AUDIO_USECASE_MAX] = {
+const char * const use_case_table[AUDIO_USECASE_MAX] = {
[USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = "deep-buffer-playback",
[USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = "low-latency-playback",
[USECASE_AUDIO_PLAYBACK_MULTI_CH] = "multi-channel-playback",
@@ -2083,7 +2083,9 @@
int val;
int ret;
- ALOGV("%s: enter: %s", __func__, kvpairs);
+ ALOGD("%s: enter: %s", __func__, kvpairs);
+
+ pthread_mutex_lock(&adev->lock);
parms = str_parms_create_str(kvpairs);
voice_set_parameters(adev, parms);
@@ -2125,7 +2127,6 @@
default:
ALOGE("%s: unexpected rotation of %d", __func__, val);
}
- pthread_mutex_lock(&adev->lock);
if (adev->speaker_lr_swap != reverse_speakers) {
adev->speaker_lr_swap = reverse_speakers;
// only update the selected device if there is active pcm playback
@@ -2139,11 +2140,12 @@
}
}
}
- pthread_mutex_unlock(&adev->lock);
}
audio_extn_set_parameters(adev, parms);
str_parms_destroy(parms);
+
+ pthread_mutex_unlock(&adev->lock);
ALOGV("%s: exit with code(%d)", __func__, ret);
return ret;
}
@@ -2156,12 +2158,15 @@
struct str_parms *query = str_parms_create_str(keys);
char *str;
+ pthread_mutex_lock(&adev->lock);
+
audio_extn_get_parameters(adev, query, reply);
platform_get_parameters(adev->platform, query, reply);
str = str_parms_to_str(reply);
str_parms_destroy(query);
str_parms_destroy(reply);
+ pthread_mutex_unlock(&adev->lock);
ALOGV("%s: exit: returns - %s", __func__, str);
return str;
}
@@ -2217,7 +2222,13 @@
static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
{
- return voice_set_mic_mute((struct audio_device *)dev, state);
+ int ret;
+
+ pthread_mutex_lock(&adev->lock);
+ ret = voice_set_mic_mute((struct audio_device *)dev, state);
+ pthread_mutex_unlock(&adev->lock);
+
+ return ret;
}
static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)