Skip to content

Commit

Permalink
alsa_sound: fix for SIP call mute issue.
Browse files Browse the repository at this point in the history
-Mute VOIP through audio path is not supported by kernel,
 so calling setVoipMicMute() to disable ""Voip Tx Mute"" fails
-Mute VOIP by cleanning buffers read if setMicMute is set
-Remove mVoipMicMute and use mMicMute for voice and VOIP

Bug: 7213748
Change-Id: I62be8456447425cbd1521083782802effcb6d326
Signed-off-by: Iliyan Malchev <malchev@google.com>
  • Loading branch information
SathishKumar Mani authored and The Android Automerger committed Sep 28, 2012
1 parent cda1a83 commit 1af98a6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
2 changes: 0 additions & 2 deletions alsa_sound/ALSAStreamOps.cpp
Expand Up @@ -61,7 +61,6 @@ ALSAStreamOps::~ALSAStreamOps()
}
}
mParent->mVoipStreamCount = 0;
mParent->mVoipMicMute = 0;
mParent->mVoipBitRate = 0;
}
close();
Expand Down Expand Up @@ -352,7 +351,6 @@ void ALSAStreamOps::close()
ALOGD("close");
if((!strncmp(mHandle->useCase, SND_USE_CASE_VERB_IP_VOICECALL, strlen(SND_USE_CASE_VERB_IP_VOICECALL))) ||
(!strncmp(mHandle->useCase, SND_USE_CASE_MOD_PLAY_VOIP, strlen(SND_USE_CASE_MOD_PLAY_VOIP)))) {
mParent->mVoipMicMute = false;
mParent->mVoipBitRate = 0;
mParent->mVoipStreamCount = 0;
}
Expand Down
38 changes: 8 additions & 30 deletions alsa_sound/AudioHardwareALSA.cpp
Expand Up @@ -71,8 +71,8 @@ AudioHardwareInterface *AudioHardwareALSA::create() {
}

AudioHardwareALSA::AudioHardwareALSA() :
mALSADevice(0),mVoipStreamCount(0),mVoipMicMute(false),mVoipBitRate(0)
,mCallState(0),mAcdbHandle(NULL),mCsdHandle(NULL)
mALSADevice(0),mVoipStreamCount(0),mVoipBitRate(0)
,mCallState(0),mAcdbHandle(NULL),mCsdHandle(NULL),mMicMute(0)
{
FILE *fp;
char soundCardInfo[200];
Expand Down Expand Up @@ -737,7 +737,6 @@ AudioHardwareALSA::openOutputStream(uint32_t devices,
}
if(voipstream_active == false) {
mVoipStreamCount = 0;
mVoipMicMute = false;
alsa_handle_t alsa_handle;
unsigned long bufferSize;
if(*sampleRate == VOIP_SAMPLING_RATE_8K) {
Expand Down Expand Up @@ -1032,7 +1031,6 @@ AudioHardwareALSA::openInputStream(uint32_t devices,
}
if(voipstream_active == false) {
mVoipStreamCount = 0;
mVoipMicMute = false;
alsa_handle_t alsa_handle;
unsigned long bufferSize;
if(*sampleRate == VOIP_SAMPLING_RATE_8K) {
Expand Down Expand Up @@ -1291,39 +1289,19 @@ AudioHardwareALSA::closeInputStream(AudioStreamIn* in)

status_t AudioHardwareALSA::setMicMute(bool state)
{
int newMode = mode();
ALOGD("setMicMute newMode %d",newMode);
if(newMode == AudioSystem::MODE_IN_COMMUNICATION) {
if (mVoipMicMute != state) {
mVoipMicMute = state;
ALOGD("setMicMute: mVoipMicMute %d", mVoipMicMute);
if(mALSADevice) {
mALSADevice->setVoipMicMute(state);
}
}
} else {
if (mMicMute != state) {
mMicMute = state;
ALOGD("setMicMute: mMicMute %d", mMicMute);
if(mALSADevice) {
if(mCSCallActive == CS_ACTIVE)
mALSADevice->setMicMute(state);
if(mVolteCallActive == IMS_ACTIVE)
mALSADevice->setVoLTEMicMute(state);
}
if (mMicMute != state) {
mMicMute = state;
ALOGD("setMicMute: mMicMute %d", mMicMute);
if(mALSADevice) {
mALSADevice->setMicMute(state);
}
}
return NO_ERROR;
}

status_t AudioHardwareALSA::getMicMute(bool *state)
{
int newMode = mode();
if(newMode == AudioSystem::MODE_IN_COMMUNICATION) {
*state = mVoipMicMute;
} else {
*state = mMicMute;
}
*state = mMicMute;
return NO_ERROR;
}

Expand Down
1 change: 0 additions & 1 deletion alsa_sound/AudioHardwareALSA.h
Expand Up @@ -566,7 +566,6 @@ class AudioHardwareALSA : public AudioHardwareBase
* Settings and Qualcomm Settings applications */
uint32_t mDevSettingsFlag;
uint32_t mVoipStreamCount;
bool mVoipMicMute;
uint32_t mVoipBitRate;
uint32_t mIncallMode;

Expand Down
5 changes: 4 additions & 1 deletion alsa_sound/AudioStreamInALSA.cpp
Expand Up @@ -445,6 +445,10 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
else {
read += static_cast<ssize_t>((period_size));
read_pending -= period_size;
//Set mute by cleanning buffers read
if (mParent->mMicMute) {
memset(buffer, 0, period_size);
}
buffer = ((uint8_t *)buffer) + period_size;
}

Expand Down Expand Up @@ -491,7 +495,6 @@ status_t AudioStreamInALSA::close()
return NO_ERROR;
}
mParent->mVoipStreamCount = 0;
mParent->mVoipMicMute = 0;
#ifdef QCOM_USBAUDIO_ENABLED
} else {
ALOGD("Deregistering REC bit, musbRecordingState:%d", mParent->musbRecordingState);
Expand Down
1 change: 0 additions & 1 deletion alsa_sound/AudioStreamOutALSA.cpp
Expand Up @@ -299,7 +299,6 @@ status_t AudioStreamOutALSA::close()
return NO_ERROR;
}
mParent->mVoipStreamCount = 0;
mParent->mVoipMicMute = 0;
}
#ifdef QCOM_USBAUDIO_ENABLED
else if((!strcmp(mHandle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
Expand Down

0 comments on commit 1af98a6

Please sign in to comment.