hal: avoid resetting to speaker if HDMI is still connected

Burst of sound is perceived over speaker during song switch, and the
cause is that APM closeOutput triggers resetting device to speaker when
playback ends.

Resetting to speaker is intended only when HDMI is unplugged, so we need
to avoid doing so if HDMI is still connected.

Change-Id: I32bb809ea037f7f180d613cacacc7e3b0210d91c
CRs-Fixed: 997689
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index a8d7d0e..b419178 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2246,17 +2246,17 @@
         pthread_mutex_lock(&adev->lock);
 
         /*
-         * When HDMI cable is unplugged/usb hs is disconnected the
-         * music playback is paused and the policy manager sends routing=0
-         * But the audioflingercontinues to write data until standby time
-         * (3sec). As the HDMI core is turned off, the write gets blocked.
+         * When HDMI cable is unplugged the music playback is paused and
+         * the policy manager sends routing=0. But the audioflinger continues
+         * to write data until standby time (3sec). As the HDMI core is
+         * turned off, the write gets blocked.
          * Avoid this by routing audio to speaker until standby.
          */
-        if ((out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL ||
-                out->devices == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET) &&
-                val == AUDIO_DEVICE_NONE) {
-            if (!audio_extn_dolby_is_passthrough_stream(out))
-                val = AUDIO_DEVICE_OUT_SPEAKER;
+        if ((out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL) &&
+                (val == AUDIO_DEVICE_NONE) &&
+                !audio_extn_dolby_is_passthrough_stream(out) &&
+                (platform_get_edid_info(adev->platform) != 0) /* HDMI disconnected */) {
+            val = AUDIO_DEVICE_OUT_SPEAKER;
         }
 
         /*