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 c847291..14d2325 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1025,10 +1025,12 @@
#ifndef FM_POWER_OPT
#define audio_extn_fm_set_parameters(adev, parms) (0)
#define audio_extn_fm_get_parameters(query, reply) (0)
+#define audio_extn_fm_route_on_selected_device(adev, device) (0)
#else
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);
#endif
#ifndef APTX_DECODER_ENABLED
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index 0a048cd..ade6a7e 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -389,4 +389,25 @@
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);
+ }
+ }
+ }
+ }
+}
+
#endif /* FM_POWER_OPT end */
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3db4af1..c99b449 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3698,6 +3698,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);