Skip to content

Commit

Permalink
tamsui: ifdef unused QCOM_FM
Browse files Browse the repository at this point in the history
Change-Id: I3ed322dff6e14c36310481216e38e4c1b4a22afc
  • Loading branch information
freexperia committed Jun 15, 2013
1 parent 873f88f commit a303d50
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions libaudio/AudioPolicyManager.cpp
Expand Up @@ -243,6 +243,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
break;
}
#ifdef QCOM_FM
if (mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM) {
device |= AudioSystem::DEVICE_OUT_FM;
if(FM_ANALOG == getFMMode()){
Expand All @@ -252,6 +253,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
device &= ~(device & AudioSystem::DEVICE_OUT_WIRED_HEADSET);
}
}
#endif
if (device == 0) {
ALOGE("getDeviceForStrategy() no device found for STRATEGY_MEDIA");
}
Expand Down Expand Up @@ -279,8 +281,12 @@ uint32_t AudioPolicyManager::checkDeviceMuteStrategies(AudioOutputDescriptor *ou

uint32_t muteWaitMs = 0;
audio_devices_t device = outputDesc->device();
bool shouldMute = (outputDesc->refCount() != 0) &&
(AudioSystem::popCount(device) >= (device & AUDIO_DEVICE_OUT_FM ? 3 : 2));
bool shouldMute = (outputDesc->refCount() != 0)
#ifdef QCOM_FM
&& (AudioSystem::popCount(device) >= (device & AUDIO_DEVICE_OUT_FM ? 3 : 2));
#else
;
#endif
// temporary mute output if device selection changes to avoid volume bursts due to
// different per device volumes
bool tempMute = (outputDesc->refCount() != 0) && (getDeviceForVolume(device) != getDeviceForVolume(prevDevice));
Expand Down Expand Up @@ -367,6 +373,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
{
// handle output device connection
case AudioSystem::DEVICE_STATE_AVAILABLE:
#ifdef QCOM_FM
if(device == AudioSystem::DEVICE_OUT_FM){
char value[PROPERTY_VALUE_MAX];
fm_modes fmMode = FM_DIGITAL;
Expand All @@ -389,6 +396,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
ALOGW("FM started in %d Mode",fmMode);
}
}
#endif
if (mAvailableOutputDevices & device) {
ALOGW("setDeviceConnectionState() device already connected: %x", device);
return INVALID_OPERATION;
Expand Down Expand Up @@ -430,6 +438,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
break;
// handle output device disconnection
case AudioSystem::DEVICE_STATE_UNAVAILABLE: {
#ifdef QCOM_FM
if(device == AudioSystem::DEVICE_OUT_FM){
uint32_t newDevice;
fm_modes prevFmMode = getFMMode();
Expand All @@ -444,6 +453,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
setOutputDevice(mPrimaryOutput, AUDIO_DEVICE_OUT_WIRED_HEADSET, true);
}
}
#endif
if (!(mAvailableOutputDevices & device)) {
ALOGW("setDeviceConnectionState() device not connected: %x", device);
return INVALID_OPERATION;
Expand Down Expand Up @@ -473,6 +483,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
}

audio_devices_t newDevice = AudioPolicyManagerBase::getNewDevice(mPrimaryOutput, false /*fromCache*/);
#ifdef QCOM_FM
if (device == AudioSystem::DEVICE_OUT_FM) {
if (state == AudioSystem::DEVICE_STATE_AVAILABLE) {
mOutputs.valueFor(mPrimaryOutput)->changeRefCount(AudioSystem::FM, 1);
Expand All @@ -484,6 +495,7 @@ status_t AudioPolicyManager::setDeviceConnectionState(AudioSystem::audio_devices
newDevice = getDeviceForStrategy(STRATEGY_MEDIA, false);
}
}
#endif
setOutputDevice(mPrimaryOutput, newDevice);
checkA2dpSuspend();
AudioPolicyManagerBase::checkOutputForAllStrategies();
Expand Down Expand Up @@ -682,12 +694,14 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(int inputSource)
device = AudioSystem::DEVICE_IN_VOICE_CALL;
}
break;
#ifdef QCOM_FM
case AUDIO_SOURCE_FM_RX:
device = AudioSystem::DEVICE_IN_FM_RX;
break;
case AUDIO_SOURCE_FM_RX_A2DP:
device = AudioSystem::DEVICE_IN_FM_RX_A2DP;
break;
#endif
default:
ALOGW("getDeviceForInputSource() invalid input source %d", inputSource);
break;
Expand Down Expand Up @@ -742,6 +756,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output,
}
}
uint32_t NewDevice = (uint32_t)AudioPolicyManagerBase::getNewDevice(output, true);
#ifdef QCOM_FM
if((stream == AudioSystem::SYSTEM) && (FM_ANALOG == getFMMode())
&& (NewDevice == AudioSystem::DEVICE_OUT_FM))
{
Expand All @@ -750,6 +765,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output,
muteWaitMs = setOutputDevice(output, (audio_devices_t)NewDevice, true);
}
else
#endif
muteWaitMs = setOutputDevice(output, (audio_devices_t)NewDevice, force);

// handle special case for sonification while in call
Expand Down Expand Up @@ -893,9 +909,11 @@ audio_devices_t AudioPolicyManager::getDeviceForVolume(audio_devices_t device)
if (device & AUDIO_DEVICE_OUT_SPEAKER) {
device = AUDIO_DEVICE_OUT_SPEAKER;
}
#ifdef QCOM_FM
else if (device & AUDIO_DEVICE_OUT_FM) {
device = AUDIO_DEVICE_OUT_FM;
}
#endif
else if((device & AUDIO_DEVICE_OUT_WIRED_HEADSET) != 0) {
device = AUDIO_DEVICE_OUT_WIRED_HEADSET;
}
Expand Down Expand Up @@ -932,8 +950,11 @@ status_t AudioPolicyManager::checkAndSetVolume(int stream, int index, audio_io_h
// 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]
|| (stream == AudioSystem::FM) || force) {
if (volume != mOutputs.valueFor(output)->mCurVolume[stream]
#ifdef QCOM_FM
|| (stream == AudioSystem::FM)
#endif
|| force) {
mOutputs.valueFor(output)->mCurVolume[stream] = volume;
ALOGVV("checkAndSetVolume() for output %d stream %d, volume %f, delay %d", output, stream, volume, delayMs);
if (stream == AudioSystem::VOICE_CALL ||
Expand Down Expand Up @@ -962,17 +983,22 @@ status_t AudioPolicyManager::checkAndSetVolume(int stream, int index, audio_io_h
voiceVolume = 1.0;
}

if ((voiceVolume != mLastVoiceVolume && output == mPrimaryOutput) &&
(!(mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM))) {
if ((voiceVolume != mLastVoiceVolume && output == mPrimaryOutput)
#ifdef QCOM_FM
&& (!(mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM))
#endif
){
mpClientInterface->setVoiceVolume(voiceVolume, delayMs);
mLastVoiceVolume = voiceVolume;
}
#ifdef QCOM_FM
} else if ((stream == AudioSystem::FM) && (mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM)) {
float fmVolume = -1.0;
fmVolume = (float)index/(float)mStreams[stream].mIndexMax;
if (fmVolume >= 0 && output == mPrimaryOutput) {
mpClientInterface->setFmVolume(fmVolume, delayMs);
}
#endif
}
return NO_ERROR;
}
Expand Down

0 comments on commit a303d50

Please sign in to comment.