Audio: Add routing option between HDMI speakers and device speakers

Add option that routing  between HDMI audio output and device audio
output, when HDMI is connected.

Change-Id: I9bbe9b1cbee5b6659502dae386c086f37bef2120
audio: primary desc check for sonification

- Audio glitches on alarm expiry if alarm starts
  on screen lock/standby mode

- On alarm expiry alarm tone will start play on combo device
  &screen unlock tone try to play on headset which results
  multiple device switch, as a result audio glitches are audible

- Fix is to treat all non-music streams as sonification
  if sonfication strategy is used by primary desc which
  will avoid device switch

Change-Id: Ie280400d5f754a8d4bd8885b6836be5e120f8783
CRs-Fixed: 514467
Crs-Fixed: 626722
hal: start voip driver independent of voip output stream

- Voip driver requires voip output stream to be opened
to start itself. But it is possible that some applications
may use voip input and normal audio output. Code changes are
done to handle this scenario.
- It is possible that some applications may use different
sample rates for voip input and voip output streams. It is
handled now in such a way that, if the sample rate of the
secondly opening stream does not match with that of the
first one, the second stream will not be allowed to open
voice path for VoIP.

Change-Id: Id9d86181eeee2c4ea0aa49a723ca92c1961a559b
CRs-fixed: 601785
hal: HFP support for setting volume

-Add support for setting volume using setparameter.

Change-Id: Id614d719324ab6b280116fd952c3fa73844ce1b0
CRs-Fixed: 596437
hal: apply TTY mode change for all voice use cases

Update devices for Voice2, VoLTE and QCHAT sessions
based on the TTY mode. This change is needed to support
enabling/disabling and switching TTY mode during
voice call.

Change-Id: I4f1fde8ce6b20fad0d24e0cd963e2c3709ff25d5
CRs-fixed: 608183
hal: Add new CSD API to reduce in call device switch delay

New CSD api is added to reduce device switch delay during voice call.
This api is called before enabling the devices so that csd voice call
sequence on MDM can run in parallel with device enable configuration
on APQ.

Change-Id: I9239ff21e1c07370516d0ed668e1e94af12f9eb2
hal: Check hfp usecase to differenciate between nb and wb

 - Need to check if the hfp session is WB or not before
   setting the device to avoid rerouting.

CRs-Fixed: 605465
Change-Id: Ice6fd2776b89e5358004071b011ac304f35dbf58
hal: Do not apply CSD voice switch API on 8960

Introduced by I9239ff21e1c07370516d0ed668e1e94af12f9eb2, not relevant
here.

Change-Id: Icb63ad5dc17029bc79f81051458b47a9ddb00bf5
audio: Update call state from RIL during silent mode

 -In silent mode, after call is rejected from Far end, RIL
  sets call state to active to play the network message and
  sets the call_state to inactive later without informing
  the telephony framework.So, setMode() is not called from
  framework.
 -Currently,we are updating call state only if there is any
  active call or call state being set from RIL is "active".
  Fix is to update the call state when inactive state is
  received from RIL for the same VSID

CRs-Fixed: 631062

Change-Id: I937341c48fd4950aab2e9e689712b47976b3c28d
postproc: Add exceptions for USB digital out

Change-Id: Idc7f926d31e855ea67dedfb579a9757316e3f526
audio: Disabled excessive logging in OMX AACEncoder

- Too many debug logs are enabled in AAC Encoder by default
- Fix is to disable all the logs except the error messages
  and logs indicating loading and unloading of the encoder

Change-Id: If4b37fb654b1c70796bfdc1c839839fab3ea20dc
CRs-Fixed: 619677
hal: update csd soft volume and mute controls

Update csd volume and mute controls with new apis which
takes ramp duration as a parameter. Set default mute
ramp duration to 20 ms.

Change-Id: Id8dcbc9bc12ac4e9c56962abc58b6bd1de0530a7
hal: fix listen and audio calibration concurency

- ACDB loader is maintaining the same calibration buffers
for both listen and audio. So there is a possibility that
the audio calibration buffers may be overwritten with listen
calibration soon after notifying the device busy state to
listen hal
- Avoid this issue by notifying listen hal before sending the
audio calibration so that listen hal can complete pushing its
calibration

Change-Id: I4d954b1287b59ee4e1510707db25f466d14dca97
hal: fix to handle voip issue when input stream starts first

- adev_open_output_stream() fails if the use case is already enabled.
Because of this, in case of VoIP, when the input stream is created
and started before creating Audio Track, then the output stream
creation fails.

- Fix this issue by giving exception for VoIP use case.

Change-Id: I5e7329d64075a09b99e5760a9050ace8c62a4e87
CRs-fixed: 651761
 Audio: Fix for audio loss on switching between speaker and USB headset

 - snd device reference count is not decremented when usb headset is
   unplugged, because touch tone is still active on usb headset.
   So when usb is plugged again device routing is not triggered as
   present and prev devices are same
 - Fix is to route audio to speaker as soon as usb headset is
   disconnected

   CRs-Fixed: 630425

Change-Id: Idfa37478fa19cd5a1c75c7e1d2f77b4dc02b311a
hal: Ensure all the mutexes are initialized

- Ensure all the mutex locks are initialized before using them,
  to avoid native crashes.

Change-Id: I7b6253f1d08a36a24d366d69004ce969d73c13e1
CRs-Fixed: 654375
hal: fix BT device switch issue for audio playback during VoIP call

- When VoIP call is active on non-BT device and if the music playback
tries to switch to BT device, it will continue to route to non-BT
device on which the VoIP call is active already.
- Fix the issue by not selecting VoIP devices for audio playback when
they are on different back ends.

Change-Id: Iff9251fcf02f897d9b1cdc17fcf27c262518ada8
CRs-fixed: 652129
policy_hal: remove VGS check for BT volume

-Currently voice volume is forced to MAX when VGS is set for BT.
 But VGS parameter is not used anymore in BT stack so it never
 set the value.
-Removed VGS check as this is deprecated and keep the behavior
 same as default policy.

Change-Id: I69de60987835cc7bfbf26e6b89eb39447423fd9d
  hal: Fix device disable/enable sequence

  In Skype call, observed no rx data when headset is inserted
  during call.

  During device switch from handset to headset, audio HAL is
  enabling the headset mixer controls first then disabling
  handset mixer controls leading to no audio during downlink
  as codec clock in 8916 is disabled due to the followed
  sequence.

  The current device switch logic doesn't make sure that all
  previous devices are disabled before enabling the selected
  devices. Fix this by changing the logic to disable all the
  previous devices first and enable the selected devices.

  CRs-Fixed: 648710

Change-Id: I0adfb62ea0ad8e2a2fe1a5473732e8bef61c492a
hal: Correct the V/I feedback PCM device for 8974

 * This got moved around after merging multisession Listen.

Change-Id: I3dcc1f1ccf1373819dcbfa296dcf781f66bae9af