fm: Restore fm on Speaker
During fm plaback even though routing device is changed from WHP
to SPK on UI, fm continues to route through WHP on targets with
shared backend for WHP and SPK. This is due to APM unaware of
routing device is change to SPK and selects WHP to play LL touch
tones causes all active usecase on SPK to move to WHP and fm
routes through WHP.
Change is to handle this scenario by re-routing fm on SPK once
standby is received for LL touch tones.
Change-Id: Ia503d4c134a3679fc2a51e2f9b7b8343e7b7cd1e
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 581b802..1e2c6b8 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1097,6 +1097,7 @@
void audio_extn_fm_set_parameters(struct audio_device *adev,
struct str_parms *parms);
void audio_extn_fm_get_parameters(struct str_parms *query, struct str_parms *reply);
+void audio_extn_fm_route_on_selected_device(struct audio_device *adev, audio_devices_t device);
#ifndef APTX_DECODER_ENABLED
#define audio_extn_aptx_dec_set_license(adev); (0)
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index b4e9ff2..435c377 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -387,3 +387,23 @@
exit:
ALOGV("%s: exit", __func__);
}
+
+void audio_extn_fm_route_on_selected_device(struct audio_device *adev, audio_devices_t device)
+{
+ struct listnode *node;
+ struct audio_usecase *usecase;
+
+ if (fmmod.is_fm_running) {
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (usecase->id == USECASE_AUDIO_PLAYBACK_FM) {
+ if (fmmod.fm_device != device) {
+ ALOGV("%s selected routing device %x current device %x"
+ "are different, reroute on selected device", __func__,
+ fmmod.fm_device, device);
+ select_devices(adev, usecase->id);
+ }
+ }
+ }
+ }
+}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 555f1e5..cc35b8c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4198,6 +4198,8 @@
if (do_stop) {
stop_output_stream(out);
}
+ // if fm is active route on selected device in UI
+ audio_extn_fm_route_on_selected_device(adev, out->devices);
pthread_mutex_unlock(&adev->lock);
}
pthread_mutex_unlock(&out->lock);