alsa_sound: Synchronization fix - standby and flush

-Standby was not waiting for DRAIN to finish before
calling standby on alsaHandle. Volume was also
not check AlsaHandle before calling it
-Fix this by adding lock and checking status of lock
CRs-Fixed: 493580

Change-Id: I318f5f120f4e02135e00962b670120f6000d49ef
Proper cleanup of Tunnel and LPA during Error

 - Cleanup of tunnel and lpa during error

Change-Id: I8792c224e55ec96102a00bd38ed4d8de85fd7e4e
Avoiding adding delay for LPA and Tunnel Device Setparameter

 - When switching between device the delay was causing output to route
   to wrong device during concurrancy.
 - This delay is not required for LPA and Tunnel mode.
 - Hence we send setparameter to Device without delay.

CRs-Fixed: 480244

Change-Id: Ia21322cb004791a8e7ba7c750628ac882f7c8372
alsa_sound: Update the usecase before enabling device

When speaker device is selected, route function enables
the TX processing path for speaker protection.
Change fixes issue where opendevice and route function try to
enable verbs for ucm usecase set function.As per UCM specification
only one verb should be active any time.

Change-Id: I9619ece0be9e1e2823321d341363470b1812d8eb
alsa_sound: Increase delay in tempmute for BT,USB,WFD devices

-WFD to BT switch while playing media causing  audio loss/noise on BT

-Before BT routing, stream is unmuted because of less latency time

-Increased temp mute time to ensure unmute after device switch

CRs-Fixed: 493835

Change-Id: I337088814258fcce060f1b139773bb63b6f21635
alsa_sound: Query BT/USB streams for audio latency

The latency of BT/USB devices should be considered during playback
on these devices. This is needed for audio and video to be in sync
when video clip is played.

CRs-Fixed: 499841
Change-Id: I5468f08b931d7a502e46399f602345590f1526dc
alsa_sound: Calculate proxy port latency

The latency of proxy port should be considered during playback
on these devices. This is needed for audio and video to be in sync
when video clip is played.

CRs-Fixed: 499841
Change-Id: Ifca7b2d20081cd8c4544d65f423243f015e8e253
alsa_sound: Fix buffer pointer mismatch in proxy

-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
-To fix this, we have to make sure that the
pointer is incremented only by the amount of data
thats actually read from the proxy

Change-Id: I42e689ccfad2548d1bbbbc13995fb3b649593bbd
alsa_sound: Flush Proxy data at high water mark

-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

Change-Id: Ie727ac07c4865c8e84f1dfda752bc4b17b84a926
alsa_sound: Increase extOutThread priority to URGENT_AUDIO

Increase extOutThread priority to URGENT_AUDIO to avoid
delays in proxy port read.

CRs-Fixed: 499841
Change-Id: I734237807ce4f489a49d8e051ff370cafcbfb300
audio/msm8660: Updates for MR2

  * update for HAL changes

Based on:
  http://review.cyanogenmod.org/46036
  http://review.cyanogenmod.org/46087

Change-Id: Id661ec2b87b0b79e2a11005180d3169a254e6f66