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

Commit 6f461b96 authored by Dhanalakshmi Siddani's avatar Dhanalakshmi Siddani Committed by Divya Narayanan Poojary
Browse files

Audio: Fix for FM off/on delay post SSR

- 8-10sec delay observed when FM is turned off/on from UI post SSR with
  touch tones enabled. If any new input request comes before FM is closed
  post SSR, pcm driver assumes AFE is still active and starts pumping data
  to AFE which is already closed due to SSR causing the delay
- Fix is to close FM session during SSR.

 CRs-Fixed: 673031

Change-Id: I4a55c6ca66d94e633e768b1d40584d5a5782e13e
parent c4565e65
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ struct fm_module {
    struct pcm *fm_pcm_tx;
    bool is_fm_running;
    float fm_volume;
    bool restart_fm;
    int scard_state;
};

static struct fm_module fmmod = {
@@ -58,6 +60,8 @@ static struct fm_module fmmod = {
  .fm_pcm_tx = NULL,
  .fm_volume = 0,
  .is_fm_running = 0,
  .restart_fm = 0,
  .scard_state = SND_CARD_STATE_ONLINE,
};

static int32_t fm_set_volume(struct audio_device *adev, float value)
@@ -213,7 +217,23 @@ void audio_extn_fm_set_parameters(struct audio_device *adev,
    float vol =0.0;

    ALOGV("%s: enter", __func__);
    ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
    if (ret >= 0) {
        char *snd_card_status = value+2;
        if (strstr(snd_card_status, "OFFLINE")) {
            fmmod.scard_state = SND_CARD_STATE_OFFLINE;
        }
        else if (strstr(snd_card_status, "ONLINE")) {
            fmmod.scard_state = SND_CARD_STATE_ONLINE;
        }
    }
    if(fmmod.is_fm_running) {
        if (fmmod.scard_state == SND_CARD_STATE_OFFLINE) {
            ALOGD("sound card is OFFLINE, stop FM");
            fm_stop(adev);
            fmmod.restart_fm = 1;
        }

        ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
                                value, sizeof(value));
        if (ret >= 0) {
@@ -222,6 +242,11 @@ void audio_extn_fm_set_parameters(struct audio_device *adev,
                select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
        }
    }
    if (fmmod.restart_fm && (fmmod.scard_state == SND_CARD_STATE_ONLINE)) {
        ALOGD("sound card is ONLINE, restart FM");
        fmmod.restart_fm = 0;
        fm_start(adev);
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HANDLE_FM,
                            value, sizeof(value));