audio : Mute FM when ringtone is played from settings

- FM audio on speaker is getting mixed up with ringtone
  when it is played from settings.
- Fix is to mute FM audio by enabling the combo device for
  sonification strategy even if the speaker is force used
  for media.
  CRs-Fixed: 574271

Change-Id: Ic595f326d7409b4cb557f5f1edf8f3bf58ce60c8
audio :Close HotWord audio source if it is already opened

- HotWord GTS test tries to record using second instance
  of HotWord Audio Source while one is already active.
  AudioPolicyManagerALSA is not closing the previous audio
  input before starting the second input.
- AudioHardwareALSA::openInputStream rejects opening
  of the second instance of audio input.
- HotWordAudioSource GTS test case fails due to above
  reasons.
- Fix is to enable the code that closes the previous
  input before starting the second audio input.
- Remove the code in openInputStream that is restricting
  the second record client. This is not needed now as it
  is already done in startInput of AudioPolicyManagerALSA

Change-Id: I63cd5061e23bef6c1f7c52cadd65833778e34018
CRs-Fixed: 591788
mm-audio: Fix openmax encoder hang during flush

Flush issued by command thread should unblock the read/write calls
in openmax component.
There is race condition between input/output thread and command
thread in openmax component due to which read/write is not unblocked
which results in a hang.
This change makes command thread to issue multiple flush when it is
wait for ack to avoid a hang.

Change-Id: Ia4486f2e53f56a8413c2115b7f418b29b4bc54c5
CRs-fixed: 466764
Merge "audio : Mute FM when ringtone is played from settings"
Merge "audio :Close HotWord audio source if it is already opened"
Merge "mm-audio: Fix openmax encoder hang during flush"
 audio: Increase the period size for USB audio

 -During USB audio playback, breaks are heard .This is
  primarily due to overruns of USB buffer from the audio
  HAL.
 -By increasing the period size of USB buffer we are
  avoiding overruns .

  CRs-Fixed: 574897

Change-Id: I78fb1bd5d7201fe789a2fcc5090eb1555af408ea
Merge " audio: Increase the period size for USB audio"
alsa_sound: Clean-up of previous Resampler for A2DP device

-During Playback, While switching from AOA USB Device to BT
 Headset, silence heard on BT headset with intermittent
 down-sampled sound.
-For AOA USB, a Resampler is using and its not getting free
 when switching to BT headset, thus Resampler is also using
 for A2DP device that is leading to down-sampled sound and
 silence.
-Releasing resampler during switchExtOut for A2DP case.

Change-Id: I8879be11886ebe482a87f8b7191582a755d7c3d7
CRs-Fixed: 568306
audio: Add support for AUXPCM BT

Atheros BT chip uses AUXPCM instead of slimbus. Audio HAL has
to use different UCM files depending on whether it's
internal or external BT chip

Change-Id: If6580ea1608b9dc8bb24be58dd2c4d2bbc331f92
Merge "audio: Add support for AUXPCM BT"
Merge "alsa_sound: Clean-up of previous Resampler for A2DP device"
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
Merge "audio: Update call state from RIL during silent mode"
audio: Close the file descriptor in error scenarios

 -In the scenario where the USB headset and proxy device
  sample rate dont match, error was returned without
  closing the file descriptor .So, the next time USB
  headset is inserted , the /proc entries are not created
  which results in the USB headset playback not started
  as the capabilities cannot be read.
 - Closing the file descriptor in the error scenario fixes
  the issue.

Change-Id: Ie45327f04cc7fff6dbcbe1268a7f34793e89641b
audio: Force route call on HAL during device disconnection

- When a wired accessory is connected/disconnected,
  setDeviceConnectionState updates the current device
  only for active outputs and also makes the corresponding
  route call on Audio HAL when the current device is not
  same as the previous device for the active outputs. As
  inactive outputs are not updated in this case, sometimes
  audio policy fails to notify device change to HAL.
  Specific scenario is mentioned below

- If headset is inserted when touch tones are disabled
  and music is in progress, LPA/tunnelled output is updated
  with headset as its current device and also respective
  route call is made on audio HAL. But low latency output
  still has speaker as its current device because it is not
  active. Later, if music is paused and headset is removed,
  setOutputDevice does not make route call on Audio HAL
  when touch tones are played. This is because the current
  device and previous device are same(speaker) for low
  latency output. So Audio HAL tries to play the touch tone
  on headset when headset is not connected.

- Fix is to force route call on HAL after every device
  disconnection irrespective of current and previous device
  being same for the specific output

Change-Id: I80d799718c980d0422d4e5f7015fcf16f001fda9
CRs-Fixed: 627903
Merge "audio: Force route call on HAL during device disconnection"
Merge "audio: Close the file descriptor in error scenarios"
audio: Starting proxy thread when there is an active stream

- Proxy thread is started from DoRouting only when previous
  and current devices are external devices. When CS call
  is ended while BT Headset is connected, we get a route
  call to ear piece intermittently and then for BT A2DP to
  resume the music playback. As previous device is not
  external device, Proxy thread is not started automatically
  in this scenario. This is blocking pcm_write call for
  touch tones as ear piece is disabled and data is not
  consumed by proxy device as well

- Fix is to start proxy thread after the route call when
  pcm_write for any stream is in progress

Change-Id: I378419977a2ac5af6cd86aa52bf0cc97a3abcee8
CRs-fixed: 661252
audio: Force route on HAL when USB headset is disconnected

- 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 force routing audio to speaker as soon as usb
  headset is disconnected
- Added similar check for HDMI device too as it applies
  for HDMI disconnection scenario too

CRs-Fixed: 655403

Change-Id: I3d66654ebc1f324b08104b586f201540f7005dd2