hal: Fix for VoIP call audio mode switch bug

- Audio mode switch between speaker and headset fails during a VoIP call
- This is because only one request is allowed by APM with Direct/VoIP
  flag to get VoIP usecase in HAL.
- If another VoIP request comes in while a VoIP session is still open,
  then the request falls back and is treated as a request for primary
  output with NONE flag.
- And if there are no low-latency sessions open and any previously
  active VoIP session is closed, then the latter VoIP request handles
  routing for primary output.
- The fix allows VoIP usecase to handle routing properly when using
  primary output.

CRs-Fixed: 2000184
Change-Id: Ibda10fe0de64f33ad34340dd0ff3b710918c4461
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 3222e0b..e89d4ac 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -284,9 +284,14 @@
             uc_info = node_to_item(node, struct audio_usecase, list);
             select_devices(adev, uc_info->id);
         }
-    } else
-        ALOGV("%s: NO-OP because out_stream_count=%d, in_stream_count=%d",
+    } else {
+        ALOGV("%s: unexpected because out_stream_count=%d, in_stream_count=%d",
                __func__, voip_data.out_stream_count, voip_data.in_stream_count);
+        uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
+        if (uc_info)
+            uc_info->stream.out = adev->primary_output;
+        ret = -EINVAL;
+    }
 
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;