hal: Fix VTS errors

Deinit speaker protection thread(Cirrus)
before deinit of platform to avoid usage of
platform NULL pointer for further underlying
function calls.

Add a check to handle NULL pointer if VTS testcases
does not open a usecase.

Change-Id: I300a9b47e80e0d8349a15ed17533e62b2e7bf214
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index c9ab383..0d58df6 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -2678,7 +2678,7 @@
                     goto param_handled;
                 list_for_each(node, &a2dp.adev->usecase_list) {
                     uc_info = node_to_item(node, struct audio_usecase, list);
-                    if (uc_info->type == PCM_PLAYBACK &&
+                    if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
                          (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                         pthread_mutex_unlock(&a2dp.adev->lock);
                         fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
@@ -2719,7 +2719,7 @@
                 }
                 list_for_each(node, &a2dp.adev->usecase_list) {
                     uc_info = node_to_item(node, struct audio_usecase, list);
-                    if (uc_info->type == PCM_PLAYBACK &&
+                    if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
                          (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                         pthread_mutex_unlock(&a2dp.adev->lock);
                         fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);