hal: Restore fm volume whenever enable fm usecase
During fm playback if there is a device switch
happening due to enable of another usecase, then fm volume
set by policy is lost when fm is resumed back. This is due to
disable and enable of the fm usecase and fm device resulting in
setting of default volume set from mixer_paths.
Change is to handle this scenario by resetting the actual fm
volume whenever fm usecase is enabled.
CRs-Fixed: 2256201
Change-Id: Ib11ab0fbbe6e038d41f53675adf3c4ca509692d0
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index 24facea..02561ba 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -166,6 +166,7 @@
int32_t pcm_dev_rx_id, pcm_dev_tx_id;
ALOGD("%s: enter", __func__);
+ fmmod.is_fm_running = true;
uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
@@ -220,9 +221,6 @@
pcm_start(fmmod.fm_pcm_rx);
pcm_start(fmmod.fm_pcm_tx);
- fmmod.is_fm_running = true;
- fm_set_volume(adev, fmmod.fm_volume, false);
-
ALOGD("%s: exit: status(%d)", __func__, ret);
return 0;
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 640c5f5..79d8d98 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -966,6 +966,7 @@
snd_device_t snd_device;
char mixer_path[MIXER_PATH_MAX_LENGTH];
struct stream_out *out = NULL;
+ int ret = 0;
if (usecase == NULL)
return -EINVAL;
@@ -995,7 +996,14 @@
strlcpy(mixer_path, use_case_table[usecase->id], MIXER_PATH_MAX_LENGTH);
platform_add_backend_name(mixer_path, snd_device, usecase);
ALOGD("%s: apply mixer and update path: %s", __func__, mixer_path);
- audio_route_apply_and_update_path(adev->audio_route, mixer_path);
+ ret = audio_route_apply_and_update_path(adev->audio_route, mixer_path);
+ if (!ret && usecase->id == USECASE_AUDIO_PLAYBACK_FM) {
+ struct str_parms *parms = str_parms_create_str("fm_restore_volume=1");
+ if (parms) {
+ audio_extn_fm_set_parameters(adev, parms);
+ str_parms_destroy(parms);
+ }
+ }
ALOGV("%s: exit", __func__);
return 0;
}
@@ -1477,11 +1485,6 @@
usecase->stream.out->volume_l,
usecase->stream.out->volume_r);
}
- if (usecase->id == USECASE_AUDIO_PLAYBACK_FM) {
- struct str_parms *parms = str_parms_create_str("fm_restore_volume=1");
- if (parms)
- audio_extn_fm_set_parameters(adev, parms);
- }
}
}
}