hal: optimize switch from combo to solo device

For playback usecases routing change, audio HAL disables sound device
if existing sound device does not match derived sound device and
enables the derived sound device. It does not check whether existing
sound device is a combination multiple devices and if one of those
devices matches with the derived sound device.

With scenarios like ringtone over speaker-and-bt-a2dp followed by
a2dp playback, we disable and re-enable bt-a2dp. This is unneeded
if a2dp backend is already active. Optimze such scenarios by
disabling only devices that do not match the derived sound device.

This change squashes the followings.
I171fbead85746a2a34632f7580f56ef40505665c
(hal: Prevent superfluous device tear down on routing change)
Id1bd00bfa5f0236400529e5771851749421ac84c
(hal: Fix combo device issue with routing change)
I4afb4a573de68f17d0ff9af63403713065bfec12
(hal: align ref_cnt of combo device and its split devices)

Change-Id: I359b8a98c76206acd9085431c393825aa6dd0425
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 863916b..0daf04e 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -738,6 +738,7 @@
 int audio_extn_utils_get_bit_width_from_string(const char *);
 int audio_extn_utils_get_sample_rate_from_string(const char *);
 int audio_extn_utils_get_channels_from_string(const char *);
+void audio_extn_utils_release_snd_device(snd_device_t snd_device);
 
 #ifdef DS2_DOLBY_DAP_ENABLED
 #define LIB_DS2_DAP_HAL "vendor/lib/libhwdaphal.so"
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index c7d3bd4..9fc87cd 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -2719,6 +2719,15 @@
     return -EINVAL;
 }
 
+void audio_extn_utils_release_snd_device(snd_device_t snd_device)
+{
+    audio_extn_dev_arbi_release(snd_device);
+    audio_extn_sound_trigger_update_device_status(snd_device,
+            ST_EVENT_SND_DEVICE_FREE);
+    audio_extn_listen_update_device_status(snd_device,
+            LISTEN_EVENT_SND_DEVICE_FREE);
+}
+
 int audio_extn_utils_get_license_params
 (
 const struct audio_device *adev,