Merge "hal: fix BT device switch issue for audio playback during VoIP call"
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index a4157f8..35b20b8 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -64,7 +64,7 @@
{
int32_t vol, ret = 0;
struct mixer_ctl *ctl;
- const char *mixer_ctl_name = "Internal FM RX Volume";
+ const char *mixer_ctl_name = FM_RX_VOLUME;
ALOGV("%s: entry", __func__);
ALOGD("%s: (%f)\n", __func__, value);
@@ -92,7 +92,6 @@
return -EINVAL;
}
mixer_ctl_set_value(ctl, 0, vol);
-
ALOGV("%s: exit", __func__);
return ret;
}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index edf941a..31c23ed 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -300,10 +300,12 @@
* control in use-case does not work because rate update takes place after
* AFE port open due to the limitation of mixer control order execution.
*/
- if (snd_device == SND_DEVICE_OUT_BT_SCO) {
+ if ((snd_device == SND_DEVICE_OUT_BT_SCO) ||
+ (snd_device == SND_DEVICE_IN_BT_SCO_MIC)) {
audio_route_apply_path(adev->audio_route, BT_SCO_SAMPLE_RATE);
audio_route_update_mixer(adev->audio_route);
- } else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB) {
+ } else if ((snd_device == SND_DEVICE_OUT_BT_SCO_WB) ||
+ (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)) {
audio_route_apply_path(adev->audio_route, BT_SCO_WB_SAMPLE_RATE);
audio_route_update_mixer(adev->audio_route);
}
@@ -437,23 +439,22 @@
/* Make sure all the streams are de-routed before disabling the device */
audio_route_update_mixer(adev->audio_route);
+ /* Make sure the previous devices to be disabled first and then enable the
+ selected devices */
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
if (switch_device[usecase->id]) {
- disable_snd_device(adev, usecase->out_snd_device, false);
+ disable_snd_device(adev, usecase->out_snd_device, true);
}
}
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
if (switch_device[usecase->id]) {
- enable_snd_device(adev, snd_device, false);
+ enable_snd_device(adev, snd_device, true);
}
}
- /* Make sure new snd device is enabled before re-routing the streams */
- audio_route_update_mixer(adev->audio_route);
-
/* Re-route all the usecases on the shared backend other than the
specified usecase to new snd devices */
list_for_each(node, &adev->usecase_list) {
@@ -507,23 +508,22 @@
/* Make sure all the streams are de-routed before disabling the device */
audio_route_update_mixer(adev->audio_route);
+ /* Make sure the previous devices to be disabled first and then enable the
+ selected devices */
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
if (switch_device[usecase->id]) {
- disable_snd_device(adev, usecase->in_snd_device, false);
+ disable_snd_device(adev, usecase->in_snd_device, true);
}
}
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
if (switch_device[usecase->id]) {
- enable_snd_device(adev, snd_device, false);
+ enable_snd_device(adev, snd_device, true);
}
}
- /* Make sure new snd device is enabled before re-routing the streams */
- audio_route_update_mixer(adev->audio_route);
-
/* Re-route all the usecases on the shared backend other than the
specified usecase to new snd devices */
list_for_each(node, &adev->usecase_list) {
@@ -699,12 +699,12 @@
/* Disable current sound devices */
if (usecase->out_snd_device != SND_DEVICE_NONE) {
disable_audio_route(adev, usecase, true);
- disable_snd_device(adev, usecase->out_snd_device, false);
+ disable_snd_device(adev, usecase->out_snd_device, true);
}
if (usecase->in_snd_device != SND_DEVICE_NONE) {
disable_audio_route(adev, usecase, true);
- disable_snd_device(adev, usecase->in_snd_device, false);
+ disable_snd_device(adev, usecase->in_snd_device, true);
}
/* Applicable only on the targets that has external modem.
@@ -1425,13 +1425,14 @@
pthread_mutex_lock(&adev->lock);
/*
- * When HDMI cable is unplugged the music playback is paused and
- * the policy manager sends routing=0. But the audioflinger
- * continues to write data until standby time (3sec).
- * As the HDMI core is turned off, the write gets blocked.
+ * When HDMI cable is unplugged/usb hs is disconnected the
+ * music playback is paused and the policy manager sends routing=0
+ * But the audioflingercontinues to write data until standby time
+ * (3sec). As the HDMI core is turned off, the write gets blocked.
* Avoid this by routing audio to speaker until standby.
*/
- if (out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL &&
+ if ((out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL ||
+ out->devices == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET) &&
val == AUDIO_DEVICE_NONE) {
val = AUDIO_DEVICE_OUT_SPEAKER;
}
diff --git a/hal/msm8916/platform.h b/hal/msm8916/platform.h
index f081912..f12697c 100644
--- a/hal/msm8916/platform.h
+++ b/hal/msm8916/platform.h
@@ -178,6 +178,8 @@
#define PLAYBACK_OFFLOAD_DEVICE 9
#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
+/* Define macro for Internal FM volume mixer */
+#define FM_RX_VOLUME "Internal FM RX Volume"
#define LOWLATENCY_PCM_DEVICE 12
#define EC_REF_RX "I2S_RX"
diff --git a/hal/msm8960/platform.h b/hal/msm8960/platform.h
index e38d801..e326785 100644
--- a/hal/msm8960/platform.h
+++ b/hal/msm8960/platform.h
@@ -118,4 +118,7 @@
#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
#define AUDIO_CAPTURE_PERIOD_COUNT 2
+/* Define macro for Internal FM volume mixer */
+#define FM_RX_VOLUME "Internal FM RX Volume"
+
#endif // QCOM_AUDIO_PLATFORM_H
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 3bd218c..209ee2b 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -245,6 +245,12 @@
#define HFP_ASM_RX_TX 24
#endif
+#ifdef PLATFORM_APQ8084
+#define FM_RX_VOLUME "Quat MI2S FM RX Volume"
+#else
+#define FM_RX_VOLUME "Internal FM RX Volume"
+#endif
+
#define LIB_CSD_CLIENT "libcsd-client.so"
/* CSD-CLIENT related functions */
typedef int (*init_t)(bool);