alsa_sound: Fix for no audio when switching between BT headsets

- mExtOutStream is not initialized in openExtOutput() but set to
  NULL in closeExtOutput() while disconnecting BT device.
- Initialize mExtOutStream in openExtOutput()

Change-Id: I3ae5f20f0cce0b8a10878a574561ac32aa3e898b
CRs-Fixed: 446922
 Fix for MT call ringtone on USB headset

- Issue:when usb headset connected MT call ringtone heard
  only on speaker and expected behaviour is ringtone should
  be heard on both speaker and usb headset.
- Fixed by defining combo device usb proxy rx speaker

Change-Id: I511b3c209f89506d6b3b3fa25067069e2107e12d
CRs-Fixed: 443227
audio: fix to play Skype calltone on earpiece instead of speaker

- Google's default AudioPolicyManager uses earpiece for Skype
  call tones, remove the code to select speaker in phone
  strategy if not in call.

CRs-Fixed: 421065

Change-Id: I4c2421e081d3ab6f7a496bacff91732dfb3cbe9c
alsa_sound: Set tunnel/lpa bit for playback over usb headset

-The tunnel/lpa bit was not being set in all scenarios when
 playback happens over usb headset.
-This resulte in no audio when trying to play the next tunnel
 mode clip.
-Fix by setting the lpa/tunnel bit if the device is usb and
 playback session is tunnel or lpa.

Change-Id: I6721a508e034c836a4aae5cc98cebb6236ee14d0
CRs-Fixed: 447677
alsa_sound: Fix for Audio routing to HDMI when BT connected

Currently when BT is connected Audio routes to HDMI when
HDMI is plugged in and expected behaviour is audio should
route to BT only as BT has higher priority than HDMI.This is
because route function is being called with HDMI device in
openOutputStream. Removing the route call will fix the issue.

Change-Id: I76933b7f19498023ad2739e6b0305d36a2c77bb6
CRs-Fixed: 451268
alsa-sound: AudioSessionOut optimization

- Skip memset(0) for tunnel mode playback in write()
- For LPA playback, call memset(0) only for partial buffers

Change-Id: Ia3cec99afa3bd9750298ebbe7aa6c5fc2ebed927
CRs-Fixed: 444041
alsa_sound: Fix usb headset record noise

-Issue: recording with USB headset has noise
-Fix: Increase the period size to 2048 so that
 number of times that the poll event executed is
 reduced which inturn matches proxy writes to DSP
 in real time

Change-Id: I5a566ce413f0c5c10cf30817b7b4095a2f45c6fa
CRs-Fixed: 426421
alsa-sound: Avoid use of extra bytes to signal seek processed

- A few bytes were reserved in the buffer written by the AudioSessionOut
  client to indicate a seek has been processed and there
  is no need to skip it.
- We won't need this method anymore and its expected the client
  take care of this.

Change-Id: Idfdeb3d41320e3e332424c13638c66ed200c0fee
alsa-sound: Use errno to check for error code of ioctl()

- ioctl() calls by definition must return -1 on failure with
  the error type set in errno.
- Therefore, the return value must not be used
  to check the error type for a failed drain ioctl().
- Use errno instead.

Change-Id: I4d6814bd0da678feaeef17bae83008d4c7376233
hardware/qcom/audio: fix memory leak in alsa_ucm.c file

 - Free the current device if no valid device is found in
   set_controls_of_usecase_for_all_devices function.

(cherry picked from commit c03520e5e6c9fe7ec35ddcb510a8ab53ebb023b5)

CRs-fixed: 421414
Change-Id: I759baaa8b3257950aa712fc2aaa28aa38a064a21
alsa_sound: Fix to prevent additioal doRouting call

- During an MO VoLTE call if BT is connected then
  no sound was heard on either side.
- When the Call state was updated for VoLTE,
  doRouting was called, which tried to set BT with
  A2DP profile as the device if BT was connected.
- Added a check to call doRouting only when an
  ACTIVE or HELD call's state is being changed.

Change-Id: I8422c024e52abd99836cadd15a2d5df9d36f2eea
CRs-fixed: 446294