diff options
author | Dhananjay Kumar <dhakumar@codeaurora.org> | 2015-10-01 13:38:37 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2016-05-11 00:12:21 +0200 |
commit | 96e68bb9b6d8d4db6fda04ddaaddb3ebc9918877 (patch) | |
tree | 709a7efc61a8f335a3a4c8a63050155d8ff858af | |
parent | 273b347458bbcb360a2637ef08f058446d80f6d4 (diff) | |
download | hardware_qcom_audio-96e68bb9b6d8d4db6fda04ddaaddb3ebc9918877.tar.gz hardware_qcom_audio-96e68bb9b6d8d4db6fda04ddaaddb3ebc9918877.tar.bz2 hardware_qcom_audio-96e68bb9b6d8d4db6fda04ddaaddb3ebc9918877.zip |
hal: audio_extn: fix pop noise when FM is interrupted by voice call
Minor pop is observed when FM playback is stopped, this is due to
derouting of loopback devices while they still have audible data.
This is causing pops even when FM is stopped after playback, but
this pop is more perceivable in case of interruption by voice call.
Fix the issue by draining unmuted data before derouting FM playback.
Change-Id: If92e43f3a15f0a9cfdf2819827c7f7a0ba852e3d
-rw-r--r-- | hal/audio_extn/fm.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c index 3961ba0e..420fb31d 100644 --- a/hal/audio_extn/fm.c +++ b/hal/audio_extn/fm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2013 The Android Open Source Project @@ -34,6 +34,7 @@ #ifdef FM_POWER_OPT #define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm" #define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume" +#define FM_LOOPBACK_DRAIN_TIME_MS 2 static struct pcm_config pcm_config_fm = { .channels = 2, @@ -64,7 +65,7 @@ static struct fm_module fmmod = { .scard_state = SND_CARD_STATE_ONLINE, }; -static int32_t fm_set_volume(struct audio_device *adev, float value) +static int32_t fm_set_volume(struct audio_device *adev, float value, bool persist) { int32_t vol, ret = 0; struct mixer_ctl *ctl; @@ -81,7 +82,8 @@ static int32_t fm_set_volume(struct audio_device *adev, float value) value = 1.0; } vol = lrint((value * 0x2000) + 0.5); - fmmod.fm_volume = value; + if (persist) + fmmod.fm_volume = value; if (!fmmod.is_fm_running) { ALOGV("%s: FM not active, ignoring set_fm_volume call", __func__); @@ -202,7 +204,7 @@ static int32_t fm_start(struct audio_device *adev) pcm_start(fmmod.fm_pcm_tx); fmmod.is_fm_running = true; - fm_set_volume(adev, fmmod.fm_volume); + fm_set_volume(adev, fmmod.fm_volume, false); ALOGD("%s: exit: status(%d)", __func__, ret); return 0; @@ -263,8 +265,11 @@ void audio_extn_fm_set_parameters(struct audio_device *adev, adev->primary_output->devices = val & ~AUDIO_DEVICE_OUT_FM; fm_start(adev); } else if (!(val & AUDIO_DEVICE_OUT_FM) - && fmmod.is_fm_running == true) + && fmmod.is_fm_running == true) { + fm_set_volume(adev, 0, false); + usleep(FM_LOOPBACK_DRAIN_TIME_MS*1000); fm_stop(adev); + } } } @@ -278,7 +283,7 @@ void audio_extn_fm_set_parameters(struct audio_device *adev, goto exit; } ALOGD("%s: set_fm_volume usecase", __func__); - fm_set_volume(adev, vol); + fm_set_volume(adev, vol, true); } exit: |