Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Viber and other VOIP apps. #1

Open
wants to merge 4 commits into
base: cm-10.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,24 @@ TARGET_USES_16BPPSURFACE_FOR_OPAQUE := true
ARCH_ARM_HAVE_32_BYTE_CACHE_LINES := true

TARGET_USES_ION := false
BOARD_HAVE_OLD_ION_API := true

TARGET_BOOTLOADER_BOARD_NAME := u8815
TARGET_OTA_ASSERT_DEVICE := u8815,hwu8815,u8818,hwu8818

TARGET_SPECIFIC_HEADER_PATH := device/huawei/u8815/include

# Audio
TARGET_QCOM_AUDIO_VARIANT := caf
TARGET_PROVIDES_LIBAUDIO := true


# Lights
TARGET_PROVIDES_LIBLIGHTS := true

# Camera
BOARD_NEEDS_MEMORYHEAPPMEM := true
COMMON_GLOBAL_CFLAGS += -DICS_CAMERA_BLOB
COMMON_GLOBAL_CFLAGS += -DICS_CAMERA_BLOB -DQCOM_VOIP_ENABLED

# GPS
BOARD_USES_QCOM_GPS := true
Expand Down
58 changes: 42 additions & 16 deletions audio/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
AudioHardware.cpp \
audio_hw_hal.cpp \
HardwarePinSwitching.c

ifeq ($(strip $(TARGET_HAS_QACT)),true)
LOCAL_SRC_FILES += \
AudioHardware_cad.cpp
else
LOCAL_SRC_FILES += \
AudioHardware.cpp
endif

ifeq ($(BOARD_HAVE_BLUETOOTH),true)
LOCAL_CFLAGS += -DWITH_A2DP
endif
Expand All @@ -36,20 +29,42 @@ ifeq ($(strip $(BOARD_USES_SRS_TRUEMEDIA)),true)
LOCAL_CFLAGS += -DSRS_PROCESSING
endif

ifeq ($(BOARD_USES_QCOM_AUDIO_LPA),true)
LOCAL_CFLAGS += -DQCOM_TUNNEL_LPA_ENABLED
endif

ifeq ($(BOARD_USES_QCOM_AUDIO_SPEECH),true)
LOCAL_CFLAGS += -DWITH_QCOM_SPEECH
endif

ifeq ($(BOARD_USES_QCOM_AUDIO_VOIPMUTE),true)
LOCAL_CFLAGS += -DWITH_QCOM_VOIPMUTE
endif

ifeq ($(BOARD_USES_QCOM_AUDIO_RESETALL),true)
LOCAL_CFLAGS += -DWITH_QCOM_RESETALL
endif

LOCAL_CFLAGS += -DQCOM_VOIP_ENABLED
LOCAL_CFLAGS += -DQCOM_TUNNEL_LPA_ENABLED

LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libmedia
libmedia \
libaudioalsa

# hack for prebuilt
$(shell mkdir -p $(OUT)/obj/SHARED_LIBRARIES/libaudioalsa_intermediates/)
$(shell touch $(OUT)/obj/SHARED_LIBRARIES/libaudioalsa_intermediates/export_includes)

ifneq ($(TARGET_SIMULATOR),true)
LOCAL_SHARED_LIBRARIES += libdl
endif

ifeq ($(strip $(TARGET_HAS_QACT)),true)
LOCAL_SHARED_LIBRARIES += libaudcal
ifeq ($(BOARD_USES_QCOM_AUDIO_CALIBRATION),true)
LOCAL_SHARED_LIBRARIES += libaudcal
LOCAL_CFLAGS += -DWITH_QCOM_CALIBRATION
endif

LOCAL_STATIC_LIBRARIES := \
Expand All @@ -63,14 +78,16 @@ LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS += -fno-short-enums

LOCAL_C_INCLUDES := $(TARGET_OUT_HEADERS)/mm-audio/audio-alsa
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audcal
ifeq ($(BOARD_USES_QCOM_AUDIO_CALIBRATION),true)
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audcal
endif
LOCAL_C_INCLUDES += hardware/libhardware/include
LOCAL_C_INCLUDES += hardware/libhardware_legacy/include
LOCAL_C_INCLUDES += frameworks/base/include
LOCAL_C_INCLUDES += system/core/include

#LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
#LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr

include $(BUILD_SHARED_LIBRARY)

Expand Down Expand Up @@ -101,8 +118,17 @@ endif

LOCAL_C_INCLUDES := hardware/libhardware_legacy/audio

#LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
#LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr

include $(BUILD_SHARED_LIBRARY)

# Load audio_policy.conf to system/etc/
include $(CLEAR_VARS)
LOCAL_MODULE := audio_policy.conf
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
LOCAL_SRC_FILES := audio_policy.conf
include $(BUILD_PREBUILT)
endif # TARGET_BOOTLOADER_BOARD_NAME
37 changes: 23 additions & 14 deletions audio/AudioHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ extern "C" {
#endif
//#include <media/AudioRecord.h>

#ifdef WITH_QCOM_VOIP_OVER_MVS
#include <linux/msm_audio_mvs.h>
#endif

//#define COMBO_DEVICE_SUPPORTED // Headset speaker combo device not supported on this target
#define COMBO_DEVICE_SUPPORTED // Headset speaker combo device not supported on this target
#define DUALMIC_KEY "dualmic_enabled"
#define TTY_MODE_KEY "tty_mode"
#define ECHO_SUPRESSION "ec_supported"
Expand Down Expand Up @@ -409,7 +412,7 @@ AudioStreamIn* AudioHardware::openInputStream(

mLock.lock();
#ifdef QCOM_VOIP_ENABLED
if(devices == AudioSystem::DEVICE_IN_COMMUNICATION) {
if ((devices == AudioSystem::DEVICE_IN_COMMUNICATION) && (*sampleRate == 8000)) {
ALOGV("Create Audio stream Voip \n");
AudioStreamInVoip* inVoip = new AudioStreamInVoip();
status_t lStatus = NO_ERROR;
Expand Down Expand Up @@ -646,7 +649,7 @@ status_t AudioHardware::setParameters(const String8& keyValuePairs)
}
#ifdef QCOM_VOIP_ENABLED

uint32_t AudioHardware::getMvsMode(int format)
uint32_t AudioHardware::getMvsMode(int format, int rate)
{
switch(format) {
case AudioSystem::PCM_16_BIT:
Expand Down Expand Up @@ -1575,8 +1578,11 @@ status_t AudioHardware::setVoiceVolume(float v)
ALOGW("setVoiceVolume(%f) over 1.0, assuming 1.0\n", v);
v = 1.0;
}
// Added 0.4 to current volume, as in voice call Mute cannot be set as minimum volume(0.00)
// setting Rx volume level as 2 for minimum and 7 as max level.
v = 0.4 + v;

int vol = lrint(v * 7.0);
int vol = lrint(v * 5.0);
ALOGD("setVoiceVolume(%f)\n", v);
ALOGI("Setting in-call volume to %d (available range is 2 to 7)\n", vol);

Expand Down Expand Up @@ -2055,9 +2061,14 @@ AudioHardware::AudioStreamInMSM72xx *AudioHardware::getActiveInput_l()
#ifdef QCOM_VOIP_ENABLED
status_t AudioHardware::setupDeviceforVoipCall(bool value)
{
ALOGV("setupDeviceforVoipCall value %d",value);
if (mMode == AudioSystem::MODE_IN_CALL && value == false) {
ALOGE("mode already set for voice call, do not change to normal");
return NO_ERROR;
}

int mode = (value ? AudioSystem::MODE_IN_COMMUNICATION : AudioSystem::MODE_NORMAL);
if (setMode(mode) != NO_ERROR) {
if (setMode(mode) == BAD_VALUE) {
ALOGV("setMode fails");
return UNKNOWN_ERROR;
}
Expand Down Expand Up @@ -2093,7 +2104,7 @@ status_t AudioHardware::AudioStreamInVoip::set(
{
ALOGD("AudioStreamInVoip::set devices = %u format = %x pChannels = %u Rate = %u \n",
devices, *pFormat, *pChannels, *pRate);
if ((pFormat == 0) || BAD_INDEX == hw->getMvsMode(*pFormat)) {
if ((pFormat == 0) || BAD_INDEX == hw->getMvsMode(*pFormat, *pRate)) {
ALOGE("Audio Format (%x) not supported \n",*pFormat);
return BAD_VALUE;
}
Expand Down Expand Up @@ -2156,7 +2167,7 @@ status_t AudioHardware::AudioStreamInVoip::set(
goto Error;
}

mvs_config.mvs_mode = mHardware->getMvsMode(*pFormat);
mvs_config.mvs_mode = mHardware->getMvsMode(*pFormat, *pRate);
status = mHardware->getMvsRateType(mvs_config.mvs_mode ,&mvs_config.rate_type);
ALOGD("set mvs config mode %d rate_type %d", mvs_config.mvs_mode, mvs_config.rate_type);
if (status < 0) {
Expand Down Expand Up @@ -2604,7 +2615,7 @@ status_t AudioHardware::AudioStreamOutMSM72xx::setParameters(const String8& keyV
if (param.getInt(key, device) == NO_ERROR) {
mDevices = device;
ALOGV("set output routing %x", mDevices);
status = mHardware->doRouting(NULL);
status = mHardware->doRouting(NULL, device);
param.remove(key);
}

Expand Down Expand Up @@ -2649,10 +2660,10 @@ status_t AudioHardware::AudioStreamOutDirect::set(
uint32_t lChannels = pChannels ? *pChannels : 0;
uint32_t lRate = pRate ? *pRate : 0;

ALOGD("set lFormat = %x lChannels= %u lRate = %u\n",
ALOGD("AudioStreamOutDirect::set lFormat = %x lChannels= %u lRate = %u\n",
lFormat, lChannels, lRate );

if ((pFormat == 0) || BAD_INDEX == hw->getMvsMode(*pFormat)) {
if ((pFormat == 0) || BAD_INDEX == hw->getMvsMode(*pFormat, lRate)) {
ALOGE("Audio Format (%x) not supported \n",*pFormat);
return BAD_VALUE;
}
Expand All @@ -2666,11 +2677,9 @@ status_t AudioHardware::AudioStreamOutDirect::set(

// check values
if ((lFormat != format()) ||
(lChannels != channels()) ||
(lRate != sampleRate())) {
(lChannels != channels())) {
if (pFormat) *pFormat = format();
if (pChannels) *pChannels = channels();
if (pRate) *pRate = sampleRate();
ALOGE(" AudioStreamOutDirect::set return bad values\n");
return BAD_VALUE;
}
Expand Down Expand Up @@ -2748,7 +2757,7 @@ ssize_t AudioHardware::AudioStreamOutDirect::write(const void* buffer, size_t by
goto Error;
}

mvs_config.mvs_mode = mHardware->getMvsMode(mFormat);
mvs_config.mvs_mode = mHardware->getMvsMode(mFormat, mSampleRate);
status = mHardware->getMvsRateType(mvs_config.mvs_mode ,&mvs_config.rate_type);
ALOGD("set mvs config mode %d rate_type %d", mvs_config.mvs_mode, mvs_config.rate_type);
if (status < 0) {
Expand Down
12 changes: 6 additions & 6 deletions audio/AudioHardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class AudioHardware : public AudioHardwareBase
#endif
protected:
virtual status_t dump(int fd, const Vector<String16>& args);
uint32_t getMvsMode(int format);
uint32_t getMvsMode(int format, int rate);
uint32_t getMvsRateType(uint32_t MvsMode, uint32_t *rateType);
status_t setupDeviceforVoipCall(bool value);

Expand Down Expand Up @@ -322,11 +322,11 @@ class AudioHardware : public AudioHardwareBase
int *pFormat,
uint32_t *pChannels,
uint32_t *pRate);
virtual uint32_t sampleRate() const {ALOGD(" AudioStreamOutDirect: SampleRate %d\n",mSampleRate); return mSampleRate; }
virtual uint32_t sampleRate() const { ALOGE(" AudioStreamOutDirect: sampleRate\n"); return 8000; }
// must be 32-bit aligned - driver only seems to like 4800
virtual size_t bufferSize() const { ALOGD(" AudioStreamOutDirect: bufferSize %d\n",mBufferSize);return mBufferSize; }
virtual uint32_t channels() const {ALOGD(" AudioStreamOutDirect: channels %d\n",mChannels); return mChannels; }
virtual int format() const {ALOGD(" AudioStreamOutDirect: format %d\n",mFormat);return mFormat; }
virtual size_t bufferSize() const { ALOGE(" AudioStreamOutDirect: bufferSize\n"); return 320; }
virtual uint32_t channels() const {ALOGD(" AudioStreamOutDirect: channels\n"); return mChannels; }
virtual int format() const {ALOGE(" AudioStreamOutDirect: format\n"); return AudioSystem::PCM_16_BIT; }
virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; }
virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; }
virtual ssize_t write(const void* buffer, size_t bytes);
Expand Down Expand Up @@ -559,7 +559,7 @@ class AudioSessionOutLPA : public AudioStreamOut
uint32_t *pChannels,
uint32_t *pRate,
AudioSystem::audio_in_acoustics acoustics);
virtual size_t bufferSize() const { return 320; }
virtual size_t bufferSize() const { return mBufferSize; }
virtual uint32_t channels() const {ALOGD(" AudioStreamInVoip: channels %d \n",mChannels); return mChannels; }
virtual int format() const { return AUDIO_HW_IN_FORMAT; }
virtual uint32_t sampleRate() const { return 8000; }
Expand Down
13 changes: 5 additions & 8 deletions audio/AudioPolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,7 @@ AudioPolicyManagerBase::IOProfile *AudioPolicyManager::getProfileForDirectOutput
uint32_t channelMask,
audio_output_flags_t flags)
{
if( !((flags & AUDIO_OUTPUT_FLAG_LPA) ||
(flags & AUDIO_OUTPUT_FLAG_TUNNEL)||
(flags & AUDIO_OUTPUT_FLAG_VOIP_RX)) )
flags = AUDIO_OUTPUT_FLAG_DIRECT;


for (size_t i = 0; i < mHwModules.size(); i++) {
if (mHwModules[i]->mHandle == 0) {
Expand All @@ -820,7 +817,7 @@ AudioPolicyManagerBase::IOProfile *AudioPolicyManager::getProfileForDirectOutput
AudioPolicyManagerBase::IOProfile *profile = mHwModules[i]->mOutputProfiles[j];
if (isCompatibleProfile(profile, device, samplingRate, format,
channelMask,
flags)) {
(audio_output_flags_t)(flags|AUDIO_OUTPUT_FLAG_DIRECT))) {
if (mAvailableOutputDevices & profile->mSupportedDevices) {
return mHwModules[i]->mOutputProfiles[j];
}
Expand Down Expand Up @@ -1104,7 +1101,7 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(int inputSource)
}
break;
case AUDIO_SOURCE_VOICE_COMMUNICATION:
device = AudioSystem::DEVICE_IN_COMMUNICATION;
device = AUDIO_DEVICE_IN_COMMUNICATION;
break;
case AUDIO_SOURCE_CAMCORDER:
if (mAvailableInputDevices & AUDIO_DEVICE_IN_BACK_MIC) {
Expand Down Expand Up @@ -1310,8 +1307,8 @@ uint32_t AudioPolicyManager::setOutputDevice(audio_io_handle_t output, audio_dev
// - the requested device is 0
// - the requested device is the same as current device and force is not specified.
// Doing this check here allows the caller to call setOutputDevice() without conditions
if ((device == 0 || device == prevDevice) && !force) {
ALOGV("setOutputDevice() setting same device %04x or null device for output %d", device, output);
if (device == 0) {
ALOGV("setOutputDevice() setting null device for output %d", output);
return muteWaitMs;
}

Expand Down
Loading