Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b726e84e authored by Dhananjay Kumar's avatar Dhananjay Kumar
Browse files

policy_hal: add support for fm device loopback

Use device connection event against AUDIO_DEVICE_OUT_FM
to configure FM device loopback.
Update primary output to get routing and volume events.

Change-Id: I5ddce36581568d377a08ea5afe470bdff4349ec7
parent 23e4fc37
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_AFE_PROXY_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM_POWER_OPT)),true)
LOCAL_CFLAGS += -DFM_POWER_OPT
endif

LOCAL_MODULE := libaudiopolicymanager

include $(BUILD_SHARED_LIBRARY)
+24 −0
Original line number Diff line number Diff line
@@ -250,6 +250,23 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d
            audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
            updateCallRouting(newDevice);
        }

#ifdef FM_POWER_OPT
        // handle FM device connection state to trigger FM AFE loopback
        if(device == AUDIO_DEVICE_OUT_FM && hasPrimaryOutput()) {
           audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
           if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
               mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, 1);
               newDevice = newDevice | AUDIO_DEVICE_OUT_FM;
           } else {
               mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, -1);
           }
           AudioParameter param = AudioParameter();
           param.addInt(String8("handle_fm"), (int)newDevice);
           mpClientInterface->setParameters(mPrimaryOutput->mIoHandle, param.toString());
        }
#endif /* FM_POWER_OPT end */

        for (size_t i = 0; i < mOutputs.size(); i++) {
            sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
            if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || (desc != mPrimaryOutput)) {
@@ -1228,6 +1245,13 @@ status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream,
            mpClientInterface->setVoiceVolume(voiceVolume, delayMs);
            mLastVoiceVolume = voiceVolume;
        }
#ifdef FM_POWER_OPT
    } else if (stream == AUDIO_STREAM_MUSIC && hasPrimaryOutput() &&
               outputDesc == mPrimaryOutput) {
        AudioParameter param = AudioParameter();
        param.addFloat(String8("fm_volume"), Volume::DbToAmpl(volumeDb));
        mpClientInterface->setParameters(mPrimaryOutput->mIoHandle, param.toString(), delayMs);
#endif /* FM_POWER_OPT end */
    }

    return NO_ERROR;