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

Commit 2dd77c27 authored by Mingming Yin's avatar Mingming Yin Committed by Gerrit - the friendly Code Review server
Browse files

policy_hal: fix for FM playback without active music stream

- Increase primary output ref count before getting new device
- This prevents to use NULL device for FM playback.

Change-Id: Idd2b36dab1990cdc1c1f603c5bdfd53b53c5c311
CRs-Fixed: 957807
parent 603ae9b0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -280,12 +280,13 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d
#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*/);
           audio_devices_t newDevice = AUDIO_DEVICE_NONE;
           if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
               mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, 1);
               newDevice = newDevice | AUDIO_DEVICE_OUT_FM;
               newDevice = (audio_devices_t)(getNewOutputDevice(mPrimaryOutput, false)|AUDIO_DEVICE_OUT_FM);
               mFMIsActive = true;
           } else {
               newDevice = (audio_devices_t)(getNewOutputDevice(mPrimaryOutput, false));
               mFMIsActive = false;
               mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, -1);
           }