summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher N. Hesse <raymanfx@gmail.com>2018-01-16 18:33:38 +0100
committerChristopher N. Hesse <raymanfx@gmail.com>2018-01-19 20:05:10 +0100
commitd462f7b86e957f858959ef5d80fd1744689ee6ea (patch)
tree0e87a8b1a2c2c499337870bb5518b69c0e95725a
parent63e78f24fd2cd6095786835835b7700b76302b48 (diff)
downloadandroid_hardware_samsung-d462f7b86e957f858959ef5d80fd1744689ee6ea.tar.gz
android_hardware_samsung-d462f7b86e957f858959ef5d80fd1744689ee6ea.tar.bz2
android_hardware_samsung-d462f7b86e957f858959ef5d80fd1744689ee6ea.zip
audio: Fix BT sample rate handling properly
This should now support both old and new headsets, as we rely on codec negotiation in the bluetooth stack for narrow/wide band switching. Change-Id: Ie9d308dfc55726fd1591a7d158f610bd267340e6
-rw-r--r--audio/audio_hw.c4
-rw-r--r--audio/voice.c20
2 files changed, 20 insertions, 4 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 169f5c7..c050dd5 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -4139,11 +4139,8 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
value,
sizeof(value));
if (ret >= 0) {
- /* TODO: Add support in voice calls */
if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0) {
adev->voice.bluetooth_wb = true;
- ALOGI("%s: Implement support for BT SCO wideband calls!!!",
- __func__);
} else {
adev->voice.bluetooth_wb = false;
}
@@ -4553,6 +4550,7 @@ static int adev_open(const hw_module_t *module, const char *name,
adev->voice.volume = 1.0f;
adev->voice.bluetooth_nrec = true;
adev->voice.in_call = false;
+ adev->voice.bluetooth_wb = false;
/* adev->cur_hdmi_channels = 0; by calloc() */
adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
diff --git a/audio/voice.c b/audio/voice.c
index 7c39022..5b5adf6 100644
--- a/audio/voice.c
+++ b/audio/voice.c
@@ -38,6 +38,17 @@
#include "audience.h"
#endif
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ void *__mptr = (void *)(ptr); \
+ ((type *)((uintptr_t)__mptr - offsetof(type, member))); })
+
static struct pcm_config pcm_config_voicecall = {
.channels = 2,
.rate = 8000,
@@ -159,6 +170,7 @@ static void stop_voice_session_bt_sco(struct voice_session *session) {
void start_voice_session_bt_sco(struct voice_session *session)
{
struct pcm_config *voice_sco_config;
+ struct voice_data *vdata = container_of(session, struct voice_data, session);
if (session->pcm_sco_rx != NULL || session->pcm_sco_tx != NULL) {
ALOGW("%s: SCO PCMs already open!\n", __func__);
@@ -167,7 +179,7 @@ void start_voice_session_bt_sco(struct voice_session *session)
ALOGV("%s: Opening SCO PCMs", __func__);
- if (session->wb_amr_type >= 1) {
+ if (vdata->bluetooth_wb) {
ALOGV("%s: pcm_config wideband", __func__);
voice_sco_config = &pcm_config_voice_sco_wb;
} else {
@@ -371,6 +383,12 @@ bool voice_session_uses_twomic(struct voice_session *session)
bool voice_session_uses_wideband(struct voice_session *session)
{
+ struct voice_data *vdata = container_of(session, struct voice_data, session);
+
+ if (session->out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
+ return vdata->bluetooth_wb;
+ }
+
return session->wb_amr_type >= 1;
}