diff options
Diffstat (limited to 'libaudio/AudioHardware.cpp')
-rw-r--r-- | libaudio/AudioHardware.cpp | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp index 3e28448..771fa5e 100644 --- a/libaudio/AudioHardware.cpp +++ b/libaudio/AudioHardware.cpp @@ -90,6 +90,7 @@ AudioHardware::AudioHardware() : mPcmOpenCnt(0), mMixerOpenCnt(0), mInCallAudioMode(false), + mVoiceVol(1.0f), mInputSource(AUDIO_SOURCE_DEFAULT), mBluetoothNrec(true), mTTYMode(TTY_MODE_OFF), @@ -370,8 +371,10 @@ status_t AudioHardware::setMode(int mode) status = AudioHardwareBase::setMode(mode); LOGV("setMode() : new %d, old %d", mMode, prevMode); if (status == NO_ERROR) { + bool modeNeedsCPActive = mMode == AudioSystem::MODE_IN_CALL || + mMode == AudioSystem::MODE_RINGTONE; // activate call clock in radio when entering in call or ringtone mode - if (prevMode == AudioSystem::MODE_NORMAL) + if (modeNeedsCPActive) { if ((!mActivatedCP) && (mSecRilLibHandle) && (connectRILDIfRequired() == OK)) { setCallClockSync(mRilClient, SOUND_CLOCK_START); @@ -393,9 +396,10 @@ status_t AudioHardware::setMode(int mode) openPcmOut_l(); openMixer_l(); setInputSource_l(AUDIO_SOURCE_DEFAULT); + setVoiceVolume_l(mVoiceVol); mInCallAudioMode = true; } - if (mMode == AudioSystem::MODE_NORMAL && mInCallAudioMode) { + if (mMode != AudioSystem::MODE_IN_CALL && mInCallAudioMode) { setInputSource_l(mInputSource); if (mMixer != NULL) { TRACE_DRIVER_IN(DRV_MIXER_GET) @@ -424,7 +428,7 @@ status_t AudioHardware::setMode(int mode) mInCallAudioMode = false; } - if (mMode == AudioSystem::MODE_NORMAL) { + if (!modeNeedsCPActive) { if(mActivatedCP) mActivatedCP = false; } @@ -573,12 +577,21 @@ size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int ch return AudioStreamInALSA::getBufferSize(sampleRate, channelCount); } - status_t AudioHardware::setVoiceVolume(float volume) { - LOGD("### setVoiceVolume"); - AutoMutex lock(mLock); + + setVoiceVolume_l(volume); + + return NO_ERROR; +} + +void AudioHardware::setVoiceVolume_l(float volume) +{ + LOGD("### setVoiceVolume_l"); + + mVoiceVol = volume; + if ( (AudioSystem::MODE_IN_CALL == mMode) && (mSecRilLibHandle) && (connectRILDIfRequired() == OK) ) { @@ -622,7 +635,6 @@ status_t AudioHardware::setVoiceVolume(float volume) setCallVolume(mRilClient, type, int_volume); } - return NO_ERROR; } status_t AudioHardware::setMasterVolume(float volume) @@ -1302,12 +1314,16 @@ status_t AudioHardware::AudioStreamOutALSA::standby() { if (mHardware == NULL) return NO_INIT; - AutoMutex lock(mLock); + mSleepReq = true; + { + AutoMutex lock(mLock); + mSleepReq = false; - { // scope for the AudioHardware lock - AutoMutex hwLock(mHardware->lock()); + { // scope for the AudioHardware lock + AutoMutex hwLock(mHardware->lock()); - doStandby_l(); + doStandby_l(); + } } return NO_ERROR; @@ -1420,9 +1436,10 @@ status_t AudioHardware::AudioStreamOutALSA::setParameters(const String8& keyValu if (mHardware == NULL) return NO_INIT; + mSleepReq = true; { AutoMutex lock(mLock); - + mSleepReq = false; if (param.getInt(String8(AudioParameter::keyRouting), device) == NO_ERROR) { if (device != 0) { @@ -1669,12 +1686,16 @@ status_t AudioHardware::AudioStreamInALSA::standby() { if (mHardware == NULL) return NO_INIT; - AutoMutex lock(mLock); + mSleepReq = true; + { + AutoMutex lock(mLock); + mSleepReq = false; - { // scope for AudioHardware lock - AutoMutex hwLock(mHardware->lock()); + { // scope for AudioHardware lock + AutoMutex hwLock(mHardware->lock()); - doStandby_l(); + doStandby_l(); + } } return NO_ERROR; } @@ -1806,8 +1827,10 @@ status_t AudioHardware::AudioStreamInALSA::setParameters(const String8& keyValue if (mHardware == NULL) return NO_INIT; + mSleepReq = true; { AutoMutex lock(mLock); + mSleepReq = false; if (param.getInt(String8(AudioParameter::keyInputSource), value) == NO_ERROR) { AutoMutex hwLock(mHardware->lock()); |