audio: fix audio drop when speaker is selected

When changing audio path to speaker while playback is active,
several hundred ms of audio are dropped. This is mostly noticeable
when a ringtone starts playing.

This change is a workaround forcing the output in standby when speaker
is selected.

The root cause must still be indentified and fixed.

Change-Id: Idef8dc1cdbf2da499a414d0b60244f91ef66e73b
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index bbd849a..850a1b1 100755
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -1415,12 +1415,24 @@
                 }
                 /* force standby if moving to/from HDMI/SPDIF or if the output
                  * device changes when in HDMI/SPDIF mode */
+
+                /* FIXME workaround for audio being dropped when switching path without forcing standby
+                 * (several hundred ms of audio can be lost: e.g beginning of a ringtone. We must understand
+                 * the root cause in audio HAL, driver or ABE.
                 if (((val & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
                         (adev->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) ||
                         ((val & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) ^
                         (adev->devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
                         (adev->devices & (AUDIO_DEVICE_OUT_AUX_DIGITAL |
                                          AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)))
+                */
+                if (((val & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
+                        (adev->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) ||
+                        ((val & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) ^
+                        (adev->devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
+                        (adev->devices & (AUDIO_DEVICE_OUT_AUX_DIGITAL |
+                                         AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
+                         (val == AUDIO_DEVICE_OUT_SPEAKER))
                     do_output_standby(out);
             }
             adev->devices &= ~AUDIO_DEVICE_OUT_ALL;