audio: fix output flag test in open_output_stream

If flag AUDIO_OUTPUT_FLAG_DIRECT is set, we should only
try to open a multi channel HDMI PCM output if flag
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD is not set.

Bug: 8174410.
Change-Id: I63fe6cabca590e70c077dea13c86c6948700e606
merge in klp-release (no-op)
hal: Fix for Audio Route issue when sound path changes

- if you make an outgoing call as mp3 playback is runnign with headset,
  Right side of headset is not functional when keep changing sound path
  from headset to speaker
- Fix the issue by separating loop related of disable/enable_snd_device

Bug: 11232052
Change-Id: Id02a6d7221c77cf4003d97749d75a062d8575d02
Merge "audio: fix output flag test in open_output_stream" into klp-dev
hal: Fix the audio loss issue on codec back end

- Start music playback, plug in and plug out headset and press
  'Next' button in the Music app immediately. Repeating these steps
  result complete loss of audio on HW codec.
- When headset is pluged out and Next is pressed immediately, the
  audio HAL triggers audio routing change from Headset to Speaker,
  and closure of compress playback driver. The later is not lock
  protected which result un protected access of back end information
  in the ALSA framework. This leads to incorrect routing and hence
  loss of audio. It is also observed that sometimes it could lead
  to crash in kernel and phone reboots.
- Fix by ensuring that the kernel driver close is also lock protected
  along with other routing events.

Bug: 11088400
Change-Id: I785effb09e5cef7ba20ee43e0ef91dc296d4e58a
hal: Support for anc/aanc/proxy audio features

Added support for  anc/aanc/proxy audio features

Change-Id: Id6ebdb9094635563cfafce9dc1d3449efe25bda4
hal: Support for usb audio features

Added support for usb audio feature and
related proxy device support

Change-Id: Ia64e9eff20fbbada6f08795686cdbc0ba462bafb
hal: Fix audio playback issue on USB headset

- Start music playback on USB headset. The playback is stopped
  after 3sec.
- A touch tone is played through low latency output path,  while
  selecting the song in the music app. This output goes to standy
  after 3sec. So the disable_snd_device() is called to reduce the
  ref count on usb headset device by 1. At this point the music
  playback (deep-buffer path) is still active. But the current
  implementation has uncondtionally calls usb_stop_playback()
  which results music playback to stop.
- Fix by ensuring the usb_stop_playback is called only when the
  device ref count goes to 0.
- Fix related minor stabilty issues

Change-Id: I979423458738e68da45973751cd918d4c1a924ea
CRs-Fixed: 572048
hal: USB audio support for msm8960

Change-Id: Ib3229c44056daa0bfcbdb6b14d9f93b374951930
Merge tag 'android-4.4.1_r1' into HEAD

Android 4.4.1 Release 1
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