diff options
| author | Giulio Cervera <giulio.cervera@gmail.com> | 2012-05-24 22:04:03 +0200 |
|---|---|---|
| committer | Giulio Cervera <giulio.cervera@gmail.com> | 2012-05-29 01:50:49 +0200 |
| commit | 4723385dedf575c3e83935c59189249183318969 (patch) | |
| tree | f983708ffbed5b5db15b563bfcb5c150b7c1fafc | |
| parent | b3a8434d243d3f51415d1f28fff1ce3b1d64726b (diff) | |
| download | android_hardware_qcom_media-4723385dedf575c3e83935c59189249183318969.tar.gz android_hardware_qcom_media-4723385dedf575c3e83935c59189249183318969.tar.bz2 android_hardware_qcom_media-4723385dedf575c3e83935c59189249183318969.zip | |
audio/msm7x30: fix voice volume on first call
- Store float voice volume got from audioflinger even if
msm_set_voice_rx_vol return an error and re-use it on next call.
- Check mic mute state before mute/unmute it.
- Remove redundant volume set.
Change-Id: Iaa65503e3dbe0464ac15c7e1cb00064b391c1123
| -rw-r--r-- | audio/msm7x30/AudioHardware.cpp | 84 | ||||
| -rw-r--r-- | audio/msm7x30/AudioHardware.h | 3 |
2 files changed, 53 insertions, 34 deletions
diff --git a/audio/msm7x30/AudioHardware.cpp b/audio/msm7x30/AudioHardware.cpp index 40d732c7..0261a28b 100644 --- a/audio/msm7x30/AudioHardware.cpp +++ b/audio/msm7x30/AudioHardware.cpp @@ -520,7 +520,7 @@ AudioHardware::AudioHardware() : mInit(false), mMicMute(true), mBluetoothNrec(true), mBluetoothId(0), mHACSetting(false), mBluetoothIdTx(0), mBluetoothIdRx(0), mOutput(0), mBluetoothVGS(false), mCurSndDevice(SND_DEVICE_CURRENT), - mVoiceVolume(VOICE_VOLUME_MAX), mTtyMode(TTY_OFF), mDualMicEnabled(false), + mVoiceVolume(1), mTtyMode(TTY_OFF), mDualMicEnabled(false), mRecordState(false), mEffectEnabled(false), mFmFd(-1) { int (*snd_get_num)(); @@ -1187,6 +1187,8 @@ status_t AudioHardware::setVoiceVolume(float v) v = 1.0; } + mVoiceVolume = v; + int vol = lrint(v * 100.0); LOGD("setVoiceVolume(%f)\n", v); LOGI("Setting in-call volume to %d (available range is 0 to 100)\n", vol); @@ -1500,7 +1502,8 @@ static status_t do_route_audio_rpc(uint32_t device, // start Voice call LOGD("Starting voice call and UnMuting the call"); msm_start_voice(); - msm_set_voice_tx_mute(0); + if (mic_mute == false) + msm_set_voice_tx_mute(0); cur_rx = new_rx_device; cur_tx = new_tx_device; addToTable(0,cur_rx,cur_tx,VOICE_CALL,true); @@ -1532,27 +1535,11 @@ static status_t do_route_audio_rpc(uint32_t device, return NO_ERROR; } -// always call with mutex held -status_t AudioHardware::doAudioRouteOrMute(uint32_t device) +status_t AudioHardware::doAudioRouteOrMuteHTC(uint32_t device) { -// the code and not removing it. -#if 0 - if (device == (uint32_t)SND_DEVICE_BT || device == (uint32_t)SND_DEVICE_CARKIT) { - if (mBluetoothId) { - device = mBluetoothId; - } else if (!mBluetoothNrec) { - device = SND_DEVICE_BT_EC_OFF; - } - } -#endif - uint32_t rx_acdb_id = 0; uint32_t tx_acdb_id = 0; - if (!isHTCPhone) - return do_route_audio_rpc(device, mMode != AudioSystem::MODE_IN_CALL, - mMicMute, rx_acdb_id, tx_acdb_id); - if (device == SND_DEVICE_BT) { if (!mBluetoothNrec) device = SND_DEVICE_BT_EC_OFF; @@ -1584,14 +1571,13 @@ status_t AudioHardware::doAudioRouteOrMute(uint32_t device) tx_acdb_id = mBTEndpoints[1].tx; LOGD("Update ACDB ID to default carkit setting"); } - } else if (mMode == AudioSystem::MODE_IN_CALL - && hac_enable && mHACSetting && + } else if (isInCall() && hac_enable && mHACSetting && device == SND_DEVICE_HANDSET) { LOGD("Update acdb id to hac profile."); rx_acdb_id = ACDB_ID_HAC_HANDSET_SPKR; tx_acdb_id = ACDB_ID_HAC_HANDSET_MIC; } else { - if (mMode == AudioSystem::MODE_IN_CALL) { + if (isInCall()) { rx_acdb_id = getACDB(MOD_RX, device); tx_acdb_id = getACDB(MOD_TX, device); } else { @@ -1603,12 +1589,43 @@ status_t AudioHardware::doAudioRouteOrMute(uint32_t device) } } + LOGV("doAudioRouteOrMuteHTC() rx acdb %d, tx acdb %d", rx_acdb_id, tx_acdb_id); + LOGV("doAudioRouteOrMuteHTC() device %x, mMode %d, mMicMute %d", + device, mMode, mMicMute); + return do_route_audio_rpc(device, !isInCall(), mMicMute, rx_acdb_id, tx_acdb_id); +} - LOGV("doAudioRouteOrMute: rx acdb %d, tx acdb %d", rx_acdb_id, tx_acdb_id); - LOGV("doAudioRouteOrMute() device %x, mMode %d, mMicMute %d", device, mMode, mMicMute); - return do_route_audio_rpc(device, - mMode != AudioSystem::MODE_IN_CALL, mMicMute, - rx_acdb_id, tx_acdb_id); +// always call with mutex held +status_t AudioHardware::doAudioRouteOrMute(uint32_t device) +{ +// BT acoustics is not supported. This might be used by OEMs. Hence commenting +// the code and not removing it. +#if 0 + if (device == (uint32_t)SND_DEVICE_BT || device == (uint32_t)SND_DEVICE_CARKIT) { + if (mBluetoothId) { + device = mBluetoothId; + } else if (!mBluetoothNrec) { + device = SND_DEVICE_BT_EC_OFF; + } + } +#endif + + status_t ret = NO_ERROR; + + if (!isHTCPhone) { + LOGV("doAudioRouteOrMute() device %d, mMode %d, mMicMute %d", + device, mMode, mMicMute); + ret = do_route_audio_rpc(device, !isInCall(), mMicMute, 0, 0); + } else + ret = doAudioRouteOrMuteHTC(device); + + if (isStreamOnAndActive(VOICE_CALL) && mMicMute == false) + msm_set_voice_tx_mute(0); + + if (isInCall()) + setVoiceVolume(mVoiceVolume); + + return ret; } status_t AudioHardware::get_mMode(void) { @@ -1637,20 +1654,21 @@ uint32_t AudioHardware::getACDB(int mode, uint32_t device) { uint32_t acdb_id = 0; int batt_temp = 0; + int vol = lrint(mVoiceVolume * 100.0); if (mMode == AudioSystem::MODE_IN_CALL && device <= SND_DEVICE_NO_MIC_HEADSET) { if (mode == MOD_RX) { switch (device) { case SND_DEVICE_HANDSET: - acdb_id = mVoiceVolume / 20 + 201; + acdb_id = vol / 20 + 201; break; case SND_DEVICE_HEADSET: case SND_DEVICE_NO_MIC_HEADSET: - acdb_id = mVoiceVolume / 20 + 401; + acdb_id = vol / 20 + 401; break; case SND_DEVICE_SPEAKER: - acdb_id = mVoiceVolume / 20 + 601; + acdb_id = vol / 20 + 601; break; default: break; @@ -1658,14 +1676,14 @@ uint32_t AudioHardware::getACDB(int mode, uint32_t device) { } else if (mode == MOD_TX) { switch (device) { case SND_DEVICE_HANDSET: - acdb_id = mVoiceVolume / 20 + 101; + acdb_id = vol / 20 + 101; break; case SND_DEVICE_HEADSET: case SND_DEVICE_NO_MIC_HEADSET: - acdb_id = mVoiceVolume / 20 + 301; + acdb_id = vol / 20 + 301; break; case SND_DEVICE_SPEAKER: - acdb_id = mVoiceVolume / 20 + 501; + acdb_id = vol / 20 + 501; break; default: break; diff --git a/audio/msm7x30/AudioHardware.h b/audio/msm7x30/AudioHardware.h index c5e07d45..5766f8c5 100644 --- a/audio/msm7x30/AudioHardware.h +++ b/audio/msm7x30/AudioHardware.h @@ -364,6 +364,7 @@ protected: private: + status_t doAudioRouteOrMuteHTC(uint32_t device); status_t doAudioRouteOrMute(uint32_t device); status_t setMicMute_nosync(bool state); status_t checkMicMute(); @@ -522,7 +523,7 @@ private: int mNumBTEndpoints; int mCurSndDevice; int m7xsnddriverfd; - uint32_t mVoiceVolume; + float mVoiceVolume; int mTtyMode; int mNoiseSuppressionState; bool mDualMicEnabled; |
