hal: memleak issue in audio service.
Devices are assigned to listnode but not cleared which is
leading to memleak.
To make sure memory leak does not happen, devices are cleared
in the listnode once done with it.
Change-Id: I023937dce0cee9735227a5ad2c93526799299962
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index afa6dca..880b377 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -5179,6 +5179,7 @@
/*handles device and call state changes*/
audio_extn_extspk_update(adev->extspk);
+ clear_devices(&new_devices);
error:
ALOGV("%s: exit: code(%d)", __func__, ret);
return ret;
@@ -10279,10 +10280,12 @@
// Update routing for stream
if (stream != NULL) {
- if (p_info->patch_type == PATCH_PLAYBACK)
+ if (p_info->patch_type == PATCH_PLAYBACK) {
ret = route_output_stream((struct stream_out *) stream, &devices);
- else if (p_info->patch_type == PATCH_CAPTURE)
+ clear_devices(&devices);
+ } else if (p_info->patch_type == PATCH_CAPTURE) {
ret = route_input_stream((struct stream_in *) stream, &devices, input_source);
+ }
if (ret < 0) {
pthread_mutex_lock(&adev->lock);
s_info->patch_handle = AUDIO_PATCH_HANDLE_NONE;