audio: Fix delay with first voice call and MT voice call
- Add csd init and deinit to HAL CTOR and DTOR
- Add conditional check for voice acdb loader
- Reducing the delay for playing the RINGTONE
before voice call is accepted saves,appr 340ms.
- on this platform reducing the delay wont affect
the RINGTONE as the delay in setting up voice
path after accepting the voice call will
compensate RINGTONE buffers with kernel and
firmware played on the device.
Change-Id: Ic69bfa38cfbe659ce09aa62691eae45982a42a76
diff --git a/alsa_sound/Android.mk b/alsa_sound/Android.mk
old mode 100755
new mode 100644
index 3dcb54c..060e48c
--- a/alsa_sound/Android.mk
+++ b/alsa_sound/Android.mk
@@ -126,11 +126,6 @@
LOCAL_CFLAGS += -DQCOM_USBAUDIO_ENABLED
LOCAL_CFLAGS += -DQCOM_VOIP_ENABLED
-
-ifeq ($(BOARD_HAVE_BLUETOOTH),true)
- LOCAL_CFLAGS += -DWITH_A2DP
-endif
-
LOCAL_SRC_FILES := \
audio_policy_hal.cpp \
AudioPolicyManagerALSA.cpp
@@ -149,13 +144,11 @@
LOCAL_STATIC_LIBRARIES := \
libmedia_helper \
- libaudiohw_legacy \
libaudiopolicy_legacy
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
- libmedia
LOCAL_C_INCLUDES += hardware/libhardware_legacy/audio
diff --git a/alsa_sound/AudioHardwareALSA.cpp b/alsa_sound/AudioHardwareALSA.cpp
index aa233ea..35b21db 100755
--- a/alsa_sound/AudioHardwareALSA.cpp
+++ b/alsa_sound/AudioHardwareALSA.cpp
@@ -1,7 +1,7 @@
/* AudioHardwareALSA.cpp
**
** Copyright 2008-2010 Wind River Systems
- ** Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ ** Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -66,6 +66,8 @@
static void (*acdb_deallocate)();
#endif
#ifdef QCOM_CSDCLIENT_ENABLED
+ static int (*csd_client_init)();
+ static int (*csd_client_deinit)();
static int (*csd_start_playback)();
static int (*csd_stop_playback)();
#endif
@@ -109,7 +111,6 @@
#endif
mBluetoothVGS = false;
mFusion3Platform = false;
- mIsVoicePathActive = false;
#ifdef QCOM_ACDB_ENABLED
mAcdbHandle = ::dlopen("/system/lib/libacdbloader.so", RTLD_NOW);
@@ -133,8 +134,17 @@
ALOGE("AudioHardware: DLOPEN not successful for CSD CLIENT");
} else {
ALOGD("AudioHardware: DLOPEN successful for CSD CLIENT");
+ csd_client_init = (int (*)())::dlsym(mCsdHandle,"csd_client_init");
+ csd_client_deinit = (int (*)())::dlsym(mCsdHandle,"csd_client_deinit");
csd_start_playback = (int (*)())::dlsym(mCsdHandle,"csd_client_start_playback");
csd_stop_playback = (int (*)())::dlsym(mCsdHandle,"csd_client_stop_playback");
+
+ if (csd_client_init == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_client_init", dlerror());
+ } else {
+ csd_client_init();
+ }
+
}
mALSADevice->setCsdHandle(mCsdHandle);
#endif
@@ -242,6 +252,7 @@
mUcMgr->acdb_handle = static_cast<void*> (mAcdbHandle);
}
#endif
+ mUcMgr->isFusion3Platform = mFusion3Platform;
}
//set default AudioParameters
@@ -322,6 +333,11 @@
#ifdef QCOM_CSDCLEINT_ENABLED
if (mCsdHandle) {
+ if (csd_client_deinit == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_client_deinit", dlerror());
+ } else {
+ csd_client_deinit();
+ }
::dlclose(mCsdHandle);
mCsdHandle = NULL;
}
@@ -717,19 +733,6 @@
param.add(key, value);
}
- key = String8(VOICE_PATH_ACTIVE);
- if (param.get(key, value) == NO_ERROR) {
- if (mIsVoicePathActive) {
- value = String8("true");
- } else {
- value = String8("false");
- }
- param.add(key, value);
-
- ALOGV("AudioHardwareALSA::getParameters() mIsVoicePathActive %d",
- mIsVoicePathActive);
- }
-
key = String8("tunneled-input-formats");
if ( param.get(key,value) == NO_ERROR ) {
ALOGD("Add tunnel AWB to audio parameter");
@@ -1902,7 +1905,6 @@
break;
}
}
- mIsVoicePathActive = false;
#ifdef QCOM_USBAUDIO_ENABLED
if(musbPlaybackState & USBPLAYBACKBIT_VOICECALL) {
@@ -1951,7 +1953,6 @@
snd_use_case_set(mUcMgr, "_enamod", modifier);
}
mALSADevice->startVoiceCall(&(*it));
- mIsVoicePathActive = true;
#ifdef QCOM_USBAUDIO_ENABLED
if((device & AudioSystem::DEVICE_OUT_ANLG_DOCK_HEADSET)||
diff --git a/alsa_sound/AudioHardwareALSA.h b/alsa_sound/AudioHardwareALSA.h
old mode 100755
new mode 100644
index 5413d86..6e69e69
--- a/alsa_sound/AudioHardwareALSA.h
+++ b/alsa_sound/AudioHardwareALSA.h
@@ -1,7 +1,7 @@
/* AudioHardwareALSA.h
**
** Copyright 2008-2010, Wind River Systems
- ** Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ ** Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -115,7 +115,6 @@
#define FENS_KEY "fens_enable"
#define ST_KEY "st_enable"
#define INCALLMUSIC_KEY "incall_music_enabled"
-#define VOICE_PATH_ACTIVE "voice_path_active"
#define ANC_FLAG 0x00000001
#define DMIC_FLAG 0x00000002
@@ -876,7 +875,6 @@
int musbPlaybackState;
int musbRecordingState;
#endif
- bool mIsVoicePathActive;
void *mAcdbHandle;
void *mCsdHandle;
diff --git a/alsa_sound/AudioPolicyManagerALSA.cpp b/alsa_sound/AudioPolicyManagerALSA.cpp
index a2db9f4..bfc29a6 100755
--- a/alsa_sound/AudioPolicyManagerALSA.cpp
+++ b/alsa_sound/AudioPolicyManagerALSA.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,8 +40,6 @@
#include <media/mediarecorder.h>
#include <stdio.h>
-#define MAX_POLL_VOICE_SETUP 20
-
namespace android_audio_legacy {
// ----------------------------------------------------------------------------
@@ -415,32 +413,18 @@
setStreamMute(AudioSystem::RING, true, mPrimaryOutput);
}
+ // Ignore the delay to enable voice call on this target as the enabling the
+ // voice call has enough delay to make sure the ringtone audio completely
+ // played out
+ if (state == AUDIO_MODE_IN_CALL && oldState == AUDIO_MODE_RINGTONE) {
+ delayMs = 40;
+ }
+
if (isStateInCall(state)) {
// Force calling of setVoiceVolume (in checkAndSetVolume) at the start of
// every call. Otherwise calls may start at max volume regardless of setting.
mLastVoiceVolume = -1.0f;
- if(!isStateInCall(oldState)) {
- audio_io_handle_t activeInput = getActiveInput();
-
- /* Block the policy manager until voice path is setup. This is
- * done to prevent telephony from signaling call connect before the
- * entire voice path is established.
- */
- for (int i = 0; i < MAX_POLL_VOICE_SETUP; i++) {
- usleep(100000);
- String8 voiceActive = mpClientInterface->getParameters(activeInput,
- String8("voice_path_active"));
-
- if (!voiceActive.compare(String8("voice_path_active=true"))) {
- ALOGV("setPhoneState: Voice path is active");
- break;
- } else {
- ALOGV("setPhoneState: voice path is not active");
- }
- }
- }
-
for (size_t i = 0; i < mOutputs.size(); i++) {
AudioOutputDescriptor *desc = mOutputs.valueAt(i);
//take the biggest latency for all outputs
diff --git a/alsa_sound/audio_policy_hal.cpp b/alsa_sound/audio_policy_hal.cpp
index 4657295..557b2c3 100644
--- a/alsa_sound/audio_policy_hal.cpp
+++ b/alsa_sound/audio_policy_hal.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,6 +90,13 @@
qap->apm->setPhoneState(state);
}
+ /* indicate a change in ringer mode */
+static void ap_set_ringer_mode(struct audio_policy *pol, uint32_t mode,
+ uint32_t mask)
+{
+ // deprecated, never called
+}
+
/* force using a specific device category for the specified usage */
static void ap_set_force_use(struct audio_policy *pol,
audio_policy_force_use_t usage,
@@ -296,6 +303,12 @@
return qap->apm->isStreamActive(stream, in_past_ms);
}
+static bool ap_is_source_active(const struct audio_policy *pol, audio_source_t source)
+{
+ const struct qcom_audio_policy *qap = to_cqap(pol);
+ return qap->apm->isSourceActive(source);
+}
+
static int ap_dump(const struct audio_policy *pol, int fd)
{
const struct qcom_audio_policy *qap = to_cqap(pol);
@@ -320,6 +333,7 @@
qap->policy.set_device_connection_state = ap_set_device_connection_state;
qap->policy.get_device_connection_state = ap_get_device_connection_state;
qap->policy.set_phone_state = ap_set_phone_state;
+ qap->policy.set_ringer_mode = ap_set_ringer_mode;
qap->policy.set_force_use = ap_set_force_use;
qap->policy.get_force_use = ap_get_force_use;
qap->policy.set_can_mute_enforced_audible =
@@ -345,6 +359,7 @@
qap->policy.unregister_effect = ap_unregister_effect;
qap->policy.set_effect_enabled = ap_set_effect_enabled;
qap->policy.is_stream_active = ap_is_stream_active;
+ qap->policy.is_source_active = ap_is_source_active;
qap->policy.dump = ap_dump;
qap->service = service;
diff --git a/libalsa-intf/alsa_ucm.c b/libalsa-intf/alsa_ucm.c
index 7766e7f..26ac1ed 100644
--- a/libalsa-intf/alsa_ucm.c
+++ b/libalsa-intf/alsa_ucm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2013, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -730,7 +730,7 @@
acdb_send_voice_cal = dlsym(uc_mgr->acdb_handle,"acdb_loader_send_voice_cal");
if (acdb_send_voice_cal == NULL) {
ALOGE("ucm: dlsym: Error:%s Loading acdb_loader_send_voice_cal", dlerror());
- } else {
+ } else if (!uc_mgr->isFusion3Platform) {
acdb_send_voice_cal(uc_mgr->current_rx_device,
uc_mgr->current_tx_device);
}
diff --git a/libalsa-intf/msm8960_use_cases.h b/libalsa-intf/msm8960_use_cases.h
index c23ac8a..a9c9210 100644
--- a/libalsa-intf/msm8960_use_cases.h
+++ b/libalsa-intf/msm8960_use_cases.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2013, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,6 +36,7 @@
#include "alsa_ucm.h"
#include "alsa_audio.h"
#include <pthread.h>
+#include <stdbool.h>
#define SND_UCM_END_OF_LIST "end"
/* ACDB Device ID macros */
@@ -173,6 +174,7 @@
card_ctxt_t *card_ctxt_ptr;
pthread_t thr;
void *acdb_handle;
+ bool isFusion3Platform;
};
#define MAX_NUM_CARDS (sizeof(card_list)/sizeof(char *))