alsa_sound: Add boundary check for alsa appl and hw ptr

for continuous playback the hw_ptr and appl_ptr may go beyond boundary.
The overflow check is required to ensure boundary check.

CRs-Fixed: 483203
Change-Id: I8c56a97ad1cc2a895f904bb9c03f23714ea61035
  alsa_sound: Maintain separate mute states for each call type.

  Mute is not proapagated to CS call session during
  SRVCC handover.

  This is due to mute state is not updated to CS call
  session when SRVCC handover happens.

  Fix is to maintain different mute states to different
  voice types, so that mute state will be updated on
  each call type independently.

  CRs-Fixed: 516986

Change-Id: I901b92b0d2509b353e62cb68666b3b7ddee42062
alsa_sound: Fix to Support in-call uplink recording

Uplink recording during voice call fails as the case was not
 getting handled while opening the input stream.
 -Added support for Incall Uplink recording in openInputStream.

GTalk call doesn't work if call is started during an existing
 recording session. All subsequent calls are failing after this
 scenario
 - Move the pcm device node open to read() call instead which will
   avoid opening the pcm device node of normal recording session
   and doesn't go into the error state. This will allow GTalk call
   to work and also all the subsequent calls to work

CRs-Fixed: 517810
Change-Id: I440ac4090b9f3e3a70b8acb4a818cfbf97e8c868
alsa_sound:Removed AWB from tunneled-input-formats

-AMRWB recording is failing because tunnelled mode is
 getting enabled in Sound Recorder use case
-Fix is to remove AWB parameter from tunneled-input-
 formats as it is not supported on A Family devices

Change-Id: I0cfc9b62639dfd179bc13af0988776a6c89999da
CRs-fixed: 521809
Merge "alsa_sound:Removed AWB from tunneled-input-formats"
Merge "alsa_sound: Fix to Support in-call uplink recording"
Merge "alsa_sound: Add boundary check for alsa appl and hw ptr"
libalsa-int: Check for valid mixer control

 When the mixer value is NULL , the mixer_close function
 crashes.
 Added a check to make sure that only a valid mixer function
 is handled

 CRs-Fixed: 516186
Change-Id: I61a45e4fbc68fbd82fdcb8f372e5b66a36487f2f
alsa_sound :Starting "UsbRecordingThread" if not started

- Recorder stop() was getting called in hangout app before the
  call got connected, this will stop UsbRecordingThread.
  Recorder set() is called with a sample rate of 48k due to which
  the USB recording thread doesnt get re-started because for VOIP
  the sample rate expected is 8/16k.

- UsbRecordingThread has to get started when the call
  gets connected.

Change-Id: I12c4d1f473224de7df2041f22fdc45cf77ac4acb
CRs-Fixed: 516270
alsa_sound : porting audio changes from 2.5

-Proxy buffering can overflow if BT playback setup takes a lot of
 time
-Fix this by increasing the proxy buffer size so that
 we will end up buffering the additional data that can come
 in during this time. CRs-Fixed: 514100

-There were glitches heard at times when listening to music over
 Bluetooth
-The issue was that due to slight scheduling delays when the
 proxy read thread in the HAL wakes up there could be more
 than one period size worth of data in the proxy. This would
 result in the proxy copying out only one period but
 incrementing the buffer by whatever thats available.
 This resulted in a glitch
-Fix this, we have to make sure that the pointer is incremented
 only by the amount of data thats actually read from the
 proxy. CRs-Fixed: 514100

-There are instances when delays in the system setup causes
 buffering to fill up in Proxy. This results in Proxy buffers
 being very close to full leading to choppy audio.
-To fix this we need to flush the data in the proxy whenever the
 high water mark is reached. The water mark is set to 40000 frames
 for now. This can be changed by changing the
 AFE_PROXY_HIGH_WATER_MARK_FRAME_COUNT. CRs-Fixed: 514100
 CRs-Fixed: 499841

-When touch tone plays for the first time while music playback is
 going on, a short break in music happens.
-In checkDeviceMuteStrategies whenever there is a change in device
 on an output, tempMute is set. However the same tempMute is used to
 decide whether to mute an already existing session on a different
 output irrespective of the current active device on that output. Due to
 this mute and unmute happens even when there is no real change in
 device on a particular output which might cause a short break in
 playback.
-Add check to ensure that active streams are temporarily muted only
 in case of a change in device on that particular output.CRs-Fixed: 495009

- Volume is not applied if playback is done on direct output
  with stream as VOICE_CALL and mode value set to MODE_NORMAL
- Voip volume is not applied in HAL if mode is not set
- Set voip volume explicitly in HAL everytime. CRs-Fixed: 493282

- Voip volume is not applied on direct output and as a result
  volume cannot be adjusted for some voicemail applications
  which opens direct output stream with mode set to IN_CALL
- Voice volume is applied only for primary output and volume
  command is not sent to HAL for direct output
- Call voice volume api for direct output as well from policy
  manager. CRs-Fixed: 493282

-While switching from Headset to speaker during FM play,
 stream is unmuted because of less latency time
-Increased temp mute time to ensure unmute after device switch
 CRs-Fixed: 493180

-When switching between headset and speaker, stream is not muted,
 which needs more time to route proper device.
-Fixed by adding IsFMEnabled from getParameters() to maintain fm
 device status,in order to Increased temp mute time to ensure more
 mute time when switch. CRs-Fixed: 493180

-Crash is observed when Hungouts and Gtalk start running
 simultaneously
-Dirver does not support multiple instances of voip call.
-Avoid creating multiple voip session if mVoipStreamCount
 is already 2. CRs-Fixed: 440160

Change-Id: I2e6dc0e7f5b49aab6350332dbdf0632b6b4e1a6c
Merge "libalsa-int: Check for valid mixer control"
alsa_sound : send voc-cal data for play voip use case

- Volume not being changed when playing voicemail
  during MODE_IN_CALL
- The calibration data was not being sent to the DSP
  for the play voip use case
- Setting the current modifier properly
  Permitting sending of calibration data despite
  no change in rx and tx devices

Change-Id: Ice9599941d3d6c115daa63c44bf4a1daa8f50ba3
CRs-Fixed: 508126
Merge "alsa_sound : porting audio changes from 2.5"
Merge "alsa_sound :Starting "UsbRecordingThread" if not started"
audio: Record uplink voice after echo cancellation

In current design, incall uplink recording is same as normal
audio recording. Some downlink data is also recorded since
there is no echo cancellation(EC) algorithm applied.
-To fix the issue, the tapping point will be moved to the point
between vocproc and encoder, because EC is applied in vocproc
module.Add voice uplink verb and modifier definition.
During voice uplink recording, use uplink verb and modifier,
instead of audio recording verb and modifier.

Change-Id: Iec4941bda1c9444dca7ed898134d7d1dec65d162
CRs-Fixed: 525425
audio: fix for volume burst during FM device switch

- Issue: Volume burst is heard during device switch
  (headphone and speaker) for FM playback
- Root cause: delayMs passed to CheckAndSetVolume is
  not applied for FM playback
- Fix: Double delayMs and apply FM volume with this delay

Change-Id: Ib7c7bd59ed584f85ea79a7606c635d60dffa3471
CRs-Fixed: 526553
alsa_sound: Configure the USB and PROXY device with proper sample rates

- For USB headset whose sample rate is other than the 8k/16k/48k
  which are supported by PROXY, ANR is observed while playback.
- getCap() function returning 0 sample rate if exact match of
  proxy supported rate is not found. This is causing device
  configuration failures in case of USB device, due to this
  playback thread closes the USB device and causes ANR.
- Fix is to configure the USB device with a sample rate supported
  by device and configure the PROXY at 48K.

CRs-Fixed: 521930
Change-Id: I8a51844d102f999618fa25f322d0ef17b38b826e
alsa_sound: Usb headset support for VOIP call

 -When the USB headset is inserted after the VOIP call
 is initiated, TX voice is not heard. This is because
 initially the VOIPREC bit for usb headset is reset as
 the USb headset is not connected.But, even after the
 headset is connected this bit is not set.
 -Set the bit accordingly after the USB headset is connected

 CRs-Fixed: 525575

Change-Id: I81bf234cb6c8f97fb1f830fc8e32b9efad0716f9
Merge "audio: Record uplink voice after echo cancellation"
Merge "alsa_sound : send voc-cal data for play voip use case"