hal: Fix issues with USB audio after disconnect

 * Stop the USB audio thread when the refcnt goes to zero.
 * Fix tracking of multiple soundcards.

Change-Id: Ia24dbcfcbcc855cde32c57dbbeb6d07af8f4cce8
hal: Correct the multi-channel output usecase selection

Both Multi-channel output on HDMI and Compress offload playback on
HDMI use cases request for a stream with AUDIO_OUTPUT_FLAG_DIRECT.
The current logic would then result selection MULTI_CH usecase.
Fix this by checking for complete match of flags to select the
use case.

Change-Id: I66df94af6c3b837a6c8054282364e1acf78e6e0f
hal: fix channel mask for m-ch offload playback

- Update channel mask with compress parameters for
  compress offload playback on HDMI device

Change-Id: I89263f56923588fcb906facfd4ae9ebf95203743
audio: Re-arrange member var initializations

Rearrange initializations of some stream_out member
variables to prevent possible uninitialized use.

CRs-Fixed: 587676
Change-Id: I7018f38f29a19b130185b285f4acf22219e4228c
hal: Use deep buffer output as primary

- The audio content in video clips, YouTube content, etc
  are being rendered through low latency path as it was
  set as default output profile. This results more power
  consumption for video playback.
- Fix this using deep buffer path as default one and use
  low latency path only for those audio tracks that
  request with AUDIO_OUTPUT_FLAG_FAST.

Change-Id: I52fafa0ec2a312bc4383c813497830e6ded071bc
CRs-Fixed: 570389

hal: Avoid duplicate primary outputs

open_output_stream API expects the default usecase to
be returned if other usecases are unavailable or unusable.
However, the output returned in this default case must be
the default primary if it exists.

 * cyanogen: This behavior is off by default.

Change-Id: Ie5cc53f077358d7039d62b09b29edb58c213bc08
hal: Disable gapless offload playback by default.

-Set the property-audio.offload.gapless.enabled to true to enable
 gapless playback by default.
-Set mixer control to the driver to decide if gapless playback needs
 to be used or not
-If gapless playback is not enabled then partial drain from HAL is
 treated as full drain.

Change-Id: Id7f4967fe528bab9097c3f609058276ec02174e1
hal: set gapless metadata for compress  offload playback

-If any of the  metadata parameters are set from the framework.
 set the gapless metadata to one.

CRs-Fixed: 588353
Change-Id: I66a79d3f64515d108585527496a754c06a441560
hal: Add support for audio effects in DSP for tunnel mode playback

Add support to enable or disable audio post processing  effects
in DSP for tunnel mode playback.

Change-Id: I4e0b01ab4ae29d4b1c7986f2a6146e18e8bce2c1
hal: fix set_parameter() returning -2 error

When setparameters() is called and if the known keys are not found,
the implementation returns -2 error.Fix this by setting error only
when keys are found and there is an error while executing corresponding
implemention.

CRs-fixed: 589280
Change-Id: If5544d6fdeac47ddfc1f7e8e18bfa81e2ef5cbc2
hal: Add property to configure the compress offload fragment size.

Add property - audio.offload.buffer.size.kbytes to configure offload
fragment size. The maximum value for fragment size is 256k. Default
value is 32k. The minimum value is 8k.

Change-Id: I9b440a420270b27f5fdba9f82de6944da0afb9d2
audio: ifdef usb audio feature

Change-Id: I486bdfe81fbe024e1797f6a5e5f8d219480001ed
hal: Add DYNAMIC_VOLUME_MIXER ifdef for AOSP compatibility

 * Upstream kernel uses a much newer compress offload implementation
   which supports gapless playback, multiple streams, and effects.
 * The volume for these streams can be controlled independently,
   so add an ifdef if we support the new mixer names.

Change-Id: I6633ec5c95ba8a8e4424be82fe90fe207a66b964
Merge "audio: ifdef usb audio feature" into cm-11.0
Visualizer: do not use GNU old-style field designators

Avoiding the use of GCC extensions improves code
portability

Change-Id: Iabe9fc84d135160367922e6d026e8608475fe8c8
voice_processing: do not use GNU old-style field designators

Not using a GNU extension improves portability

Change-Id: I732753d2efa19efb48312664c7a2155f78ceee35
hal: Various USB audio fixes

 * Increase buffer size, fix null terminator, set ACDB id

Change-Id: I8886c5b0f8ec8137e54785497a82ffe70e7bbd84
hal: Apply TMobile US voice paths to Google products only

Some non-nexus devices have issues with this, and upstream qualcomm
doesn't do it at all

Change-Id: I855791a93c7c136151182d9f8987b22894540aad