Loading libs/audioflinger/AudioPolicyManagerBase.cpp +22 −12 Original line number Diff line number Diff line Loading @@ -902,7 +902,8 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien #ifdef AUDIO_POLICY_TEST Thread(false), #endif //AUDIO_POLICY_TEST mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0), mLimitRingtoneVolume(false) mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0), mLimitRingtoneVolume(false), mLastVoiceVolume(-1.0f) { mpClientInterface = clientInterface; Loading Loading @@ -1713,28 +1714,37 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_ } float volume = computeVolume(stream, index, output, device); // do not set volume if the float value did not change if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || force) { // We actually change the volume if: // - the float value returned by computeVolume() changed // - the force flag is set if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || force) { mOutputs.valueFor(output)->mCurVolume[stream] = volume; LOGV("setStreamVolume() for output %d stream %d, volume %f, delay %d", output, stream, volume, delayMs); if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::DTMF || stream == AudioSystem::BLUETOOTH_SCO) { float voiceVolume = -1.0; // offset value to reflect actual hardware volume that never reaches 0 // 1% corresponds roughly to first step in VOICE_CALL stream volume setting (see AudioService.java) volume = 0.01 + 0.99 * volume; } mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs); } if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::BLUETOOTH_SCO) { float voiceVolume; // Force voice volume to max for bluetooth SCO as volume is managed by the headset if (stream == AudioSystem::VOICE_CALL) { voiceVolume = (float)index/(float)mStreams[stream].mIndexMax; } else if (stream == AudioSystem::BLUETOOTH_SCO) { } else { voiceVolume = 1.0; } if (voiceVolume >= 0 && output == mHardwareOutput) { if (voiceVolume != mLastVoiceVolume && output == mHardwareOutput) { mpClientInterface->setVoiceVolume(voiceVolume, delayMs); mLastVoiceVolume = voiceVolume; } } mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs); } return NO_ERROR; } Loading Loading
libs/audioflinger/AudioPolicyManagerBase.cpp +22 −12 Original line number Diff line number Diff line Loading @@ -902,7 +902,8 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien #ifdef AUDIO_POLICY_TEST Thread(false), #endif //AUDIO_POLICY_TEST mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0), mLimitRingtoneVolume(false) mPhoneState(AudioSystem::MODE_NORMAL), mRingerMode(0), mMusicStopTime(0), mLimitRingtoneVolume(false), mLastVoiceVolume(-1.0f) { mpClientInterface = clientInterface; Loading Loading @@ -1713,28 +1714,37 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_ } float volume = computeVolume(stream, index, output, device); // do not set volume if the float value did not change if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || force) { // We actually change the volume if: // - the float value returned by computeVolume() changed // - the force flag is set if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || force) { mOutputs.valueFor(output)->mCurVolume[stream] = volume; LOGV("setStreamVolume() for output %d stream %d, volume %f, delay %d", output, stream, volume, delayMs); if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::DTMF || stream == AudioSystem::BLUETOOTH_SCO) { float voiceVolume = -1.0; // offset value to reflect actual hardware volume that never reaches 0 // 1% corresponds roughly to first step in VOICE_CALL stream volume setting (see AudioService.java) volume = 0.01 + 0.99 * volume; } mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs); } if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::BLUETOOTH_SCO) { float voiceVolume; // Force voice volume to max for bluetooth SCO as volume is managed by the headset if (stream == AudioSystem::VOICE_CALL) { voiceVolume = (float)index/(float)mStreams[stream].mIndexMax; } else if (stream == AudioSystem::BLUETOOTH_SCO) { } else { voiceVolume = 1.0; } if (voiceVolume >= 0 && output == mHardwareOutput) { if (voiceVolume != mLastVoiceVolume && output == mHardwareOutput) { mpClientInterface->setVoiceVolume(voiceVolume, delayMs); mLastVoiceVolume = voiceVolume; } } mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs); } return NO_ERROR; } Loading