alsa_sound: Move pcm device node open to read function

- GTalk call doesn't work if call is started during an existing
  recording session. All subsequent calls are failing after this
  scenario
- GTalk tries to open a normal recording session initially and
  as pcm device node is busy with existing recording session it
  fails in openInputStream call and GTalk doesn't recover from
  this error again.
- 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

Change-Id: I4e2e2041c9cb8252cd059916337ce82f2a34ce50
alsa_sound: Fix for short break in music when touch tone plays

-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
Change-Id: Icbc2afa4516f700b170c1f6801135cc5ca61fbfe
alsa_sound: handle in call sonification even when refcount is not one

- If two back to back notifications are started immediately during a
  call, the second notification is still heard sometimes though it
  should be muted
- When startOutput() of second notification and stopOutput() of first
  notification are called almost at the same time respectively,
  startOutput() will not handle in call sonification as refcount is
  not equal to 1 and will not increment the mute count. But
  stopOutput() of first notification will decrement the mute count to
  0 and will result in unmuting the stream which results in this issue
- Fix this issue by handling in call sonification even when refcount
  of output is 1, so that mute count is properly maintained in such
  scenarios

Change-Id: I43304f861760a331e6bb5ecd9218ea9e184d1c50
CRs-Fixed: 501013
alsa_sound: call voice volume api for direct output also

- 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

Change-Id: I6743821f9880b024e9d78209449ff06f1eb8bec2
CRs-Fixed: 493282
alsa-sound: Fix to sound burst on switching from speaker to headset

 -During device switch stream mute(vol 0) for compressed or lpa
  stream is getting applied after the device set for primary output
  because first it check for primary output, set the device then it
  check for lpa or tunnel output and mute the stream.

 -Set the stream mute for other output(LPA or Compressed) followed
  by device setting for lpa or compressed output and then set the
  device for primary output.

CRs-Fixed: 480077

Change-Id: I6bc1ba5d8df766fbbbffaba4d44f14f7a0be666f
Merge "alsa_sound: Fix for short break in music when touch tone plays"
Merge "alsa-sound: Fix to sound burst on switching from speaker to headset"
Merge "alsa_sound: handle in call sonification even when refcount is not one"
Revert "alsa_sound: Add initial volume setting for USB headset"

This reverts commit 18e59b2c19134b32f46399592ff818cbaa3870af.
Merge "Revert "alsa_sound: Add initial volume setting for USB headset""
alsa_sound: Add initial volume setting for USB headset

Some USB headsets start at 0 volume because of this even
if the Media Player volume is maximum cannot hear any audio.
Initialize device volume before starting the playback.

CRs-Fixed: 478906
Change-Id: Ib7d598996fe88199493c429f10ff2b6ebe37fbe3
alsa_sound: Set voip volume explicitly in voice volume api

- 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

Change-Id: I956c79aaac4e30e3ed632ba553e7f41def0974b2
CRs-Fixed: 493282
alsa_sound: Changed mDevices to mCurRxDevice for StreamOut

- mDevices will be updated during route call and
  current device can change in between the start
  and write call of stream.
- In which case only the mCurRxDevice was updated
  and during write the device would not be updated
- This would create problem when switch device happens
  in session where it was alreasy set and device switch
  is ignored.
- here we use mCurRxDevice so even if there is a switch
  device in between the cur device will be used for
  routing in Stream

Change-Id: I0edc08e3b8ab4fc664570fa0ce498a7b4c4f004f
Merge "alsa_sound: Set voip volume explicitly in voice volume api"
Merge "alsa_sound: call voice volume api for direct output also"
libalsa-intf: Fix for no audio on specific USB device

- Playback volume is not initialized for USB device due to this
  on some specific headsets no audio heard even if we increase
  the playback volume to maximum.
- Fix is to explicitly initialize the volume for USB headset
  before starting the playback using mixer control. As USB
  driver supports DB_MINMAX for volume control add support
  for same in alsa_mixer.

CRs-Fixed: 478906
Change-Id: I4ebb9d8b96069f628c772da57e22478cac815c45
Merge "alsa_sound: Move pcm device node open to read function"
Merge "libalsa-intf: Fix for no audio on specific USB device"
Merge "alsa_sound: Changed mDevices to mCurRxDevice for StreamOut"
Merge "alsa_sound: Add initial volume setting for USB headset"