hal: Add option to use low latency as primary output

 * Google's original design uses the low latency output as primary for
   playback unless a series of checks are passed in the framework which
   would use deep buffer mode.  Qualcomm changed this long ago in order
   for usecases like AV which don't require low latency to be forced to
   use deep buffering. This has been a catastrophic failure ever since
   it was changed, causing crackles and pops randomly while playing
   notifications due to underruns. Either I am too stupid to make it
   work, or this behavior is fundamentally flawed.
 * Add a flag to do it Google's way, I'm tired of this bug.

Revert "hal: Use deep buffer output as primary"

This reverts commit 8f715d94926ee51baf766800f4e9c3ceec435e4c.

Change-Id: I678478798274a35fe0d117650cfd62b1a433f448
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 06fa188..89f5faf 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -63,7 +63,11 @@
 #define PROXY_OPEN_RETRY_COUNT           100
 #define PROXY_OPEN_WAIT_TIME             20
 
+#ifdef LOW_LATENCY_PRIMARY
+#define USECASE_AUDIO_PLAYBACK_PRIMARY USECASE_AUDIO_PLAYBACK_LOW_LATENCY
+#else
 #define USECASE_AUDIO_PLAYBACK_PRIMARY USECASE_AUDIO_PLAYBACK_DEEP_BUFFER
+#endif
 
 struct pcm_config pcm_config_deep_buffer = {
     .channels = 2,
@@ -2380,6 +2384,12 @@
             goto error_open;
         }
 #endif
+#ifdef LOW_LATENCY_PRIMARY
+    } else if (out->flags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
+        out->usecase = USECASE_AUDIO_PLAYBACK_DEEP_BUFFER;
+        out->config = pcm_config_deep_buffer;
+        out->sample_rate = out->config.rate;
+#endif
     } else if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
         if (config->offload_info.version != AUDIO_INFO_INITIALIZER.version ||
             config->offload_info.size != AUDIO_INFO_INITIALIZER.size) {
@@ -2492,14 +2502,20 @@
         out->usecase = USECASE_AUDIO_PLAYBACK_AFE_PROXY;
         out->config = pcm_config_afe_proxy_playback;
         adev->voice_tx_output = out;
+#ifndef LOW_LATENCY_PRIMARY
     } else if (out->flags & AUDIO_OUTPUT_FLAG_FAST) {
         out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
         out->config = pcm_config_low_latency;
         out->sample_rate = out->config.rate;
+#endif
     } else {
         /* primary path is the default path selected if no other outputs are available/suitable */
         out->usecase = USECASE_AUDIO_PLAYBACK_PRIMARY;
+#ifdef LOW_LATENCY_PRIMARY
+        out->config = pcm_config_low_latency;
+#else
         out->config = pcm_config_deep_buffer;
+#endif
         out->sample_rate = out->config.rate;
     }