hal: route to speaker, when USB HS is unplugged

 When USB headset is disconnected the music playback paused
 and the policy manager send routing=0. If USB headset is
 connected before the standby time, AFE is not closed and opened,
 so routing to speker will guarantee AFE reconfiguration and
 AFE will be opend once USB is connected again, within standby
 time.

CRs-fixed: 2219129

Change-Id: I69985dda312de34e2c86c85ac448a722f7f31f42
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 45cf3ef..081d1fe 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3682,6 +3682,18 @@
                 !audio_extn_a2dp_is_ready()) {
                 val = AUDIO_DEVICE_OUT_SPEAKER;
         }
+        /*
+        * When USB headset is disconnected the music platback paused
+        * and the policy manager send routing=0. But if the USB is connected
+        * back before the standby time, AFE is not closed and opened
+        * when USB is connected back. So routing to speker will guarantee
+        * AFE reconfiguration and AFE will be opend once USB is connected again
+        */
+        if ((out->devices & AUDIO_DEVICE_OUT_ALL_USB) &&
+                (val == AUDIO_DEVICE_NONE) &&
+                 !audio_extn_usb_connected(parms)) {
+                 val = AUDIO_DEVICE_OUT_SPEAKER;
+         }
         /* To avoid a2dp to sco overlapping / BT device improper state
          * check with BT lib about a2dp streaming support before routing
          */