hal: audio: on routing command check first voice usecase

- when routing command is received since primary output selects device
  for non voice usecase first and then selects device for voice
  usecase this adds one unnecessary device switch and additional latency
  in case of voice call setup latency.
- modify device selection logic by starting with voice usecase first
  if audio mode is in call.

Bug: 30270281

Change-Id: I2b9bb383b525793158dd6f8d2402fa73ab4c53ef
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 77dfc7a..1a77278 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1777,14 +1777,6 @@
             bool same_dev = out->devices == new_dev;
             out->devices = new_dev;
 
-            if (!out->standby) {
-                if (!same_dev) {
-                    ALOGV("update routing change");
-                    out->routing_change = true;
-                }
-                select_devices(adev, out->usecase);
-            }
-
             if (output_drives_call(adev, out)) {
                 if (!voice_is_in_call(adev)) {
                     if (adev->mode == AUDIO_MODE_IN_CALL) {
@@ -1796,6 +1788,15 @@
                     voice_update_devices_for_all_voice_usecases(adev);
                 }
             }
+
+            if (!out->standby) {
+                if (!same_dev) {
+                    ALOGV("update routing change");
+                    out->routing_change = true;
+                }
+                select_devices(adev, out->usecase);
+            }
+
         }
 
         pthread_mutex_unlock(&adev->lock);