msm8660: use policy manager from ALSA

Change-Id: I94db1a64072e94f3d85dd0fcf15565f3dd673104
msm7627a/msm8660: Port heap mask change to ion

Heap mask field passes as argument at allocation
time to specify ion heap.

Change-Id: I9b77a8bb926d938b3cc023b0de2e3ab49455155a
audio/msm8660: Add support for Tunnel Playback.

Add a new audiosession to support Tunnel playback.

Change-Id: Ic3663037f5c62b23a8a448ed5a57f9f4de5c3231
audio/msm8660: Fix for pause and resume failure.

- Resume fails if the sequence is pause,flush & resume.
- Resume of audio HAL is not resulting in driver resume.
- When the music player is paused, seek and resume fail
  this is due to the functionality built around 'mseeking',
  fix is to remove the variable

Change-Id: I2e0901dd17e86ec29435847f2ac08c761e4c4512
msm8660: Update audio policy

 * Remove hack on VOIP device
 * Set A2DP samplerate to 48KHz

Change-Id: I52f0ebe341847a9603594920bef5e71f4325fbbe
msm8660: Use a larger sample buffer for LPA

Change-Id: I292b30ae2df64297b4585181bfcd06f231430b01
msm8660: Add latency support for LPA

-Audio loss for few seconds on headset connection.
-Stream is unmute in checkDeviceMuteStrategies before device switch
occurs.
-Increase delay in tempMute to ensure unmuting happens after device
switch happens. Also change latency for LPA to correct value similar
to that of hpcm.

Change-Id: I539a4726f6b9d53bbfdc5f92a8801d5f14c360eb
CRs-Fixed: 448355
audio/msm8660: Change default audio sample rate

Return Host PCM interface sample rate based on
AF resampler quality value.

(cherry picked from commit fbaba9b736d0b77c989c80946ffb7d105641c07d)

Change-Id: I204f423051d97be5ff4dfa9805406eca61a25966
audio/msm7627a: Fix for event thread not exiting

-Event thread never exits after lpa playback.
-In error case of GET_EVENT, it is checked against wrong
condition which is always false.
-Update the check condition to avoid such issues.

Change-Id: I8274a67791ba7656eb4031952ddc55ac919df60d
msm8660: Fix routing for all AudioSessionOut types

 * Pass the new output device around so that we're not always just using
   the one in the base class. This was preventing proper routing for
   all output streams.

Change-Id: I9019d46b1268a05c6c743e40e9198b6b4898b0de
audio/msm8660: Fix for voice call mute during voip

-Voice tx is muted when call is received while voip is active.
-After voice call is received, voip moves to standby and calls
setupDeviceforVoipCall with value as false. This will mute mic
during voice call.
-Return from setupDeviceforVoipCall without moving to normal mode
if called while in call.

Change-Id: I3dcd6dacd0d8b1242019e55d9d9be6909444e49d
CRs-Fixed: 451202
audio/msm8660: VOIP bringup and add support for vocoders.

(cherry picked from commit 7f22fe5517966549f96dd02ff577e0c222f35483)

Change-Id: I8fe9eef46b7513135eb363530f4343abfa6a0f10
audio/msm8660: Change getInputBufferSize to take channel count as parameter

- SoundRecorder fails to record.
- There is no need to calculate channel count
  from channel mask as getInputBufferSize api
  already gets channel count.
- Add fix to change getInputBufferSize api to
  take channel count as argument.

(cherry picked from commit 72553946d9cc82429f58ed8a7a5489ad38722b04)

Change-Id: I5d39f5cc3eee5860b717b0fa14af1590abfb2d04
msm8660: Reject PCM recording other than 8k during voice call

As there is no resampler on record path in ADSP, Recording session
other than 8k cannot be be supported during voice call otherwise
voice Tx gets muted due to afe reconfiguration for recording
session.

Added check to reject pcm recording session other than 8k if requested
during voice call.

(cherry picked from commit 1eca4191de742b13f02df2f15d6d0ba7598d2616)

Change-Id: I84656b6864dfdc4114b2d7c1762746d1456ee2b6
CRs-Fixed: 427931 432502
audio/msm8660: Fix for voice call mute during voip

-Voice tx is muted when call is received while voip is active.
-After voice call is received, voip moves to standby and calls
setupDeviceforVoipCall with value as false. This will mute mic
during voice call.
-Return from setupDeviceforVoipCall without moving to normal mode
if called while in call.

Change-Id: I3dcd6dacd0d8b1242019e55d9d9be6909444e49d
CRs-Fixed: 451202
audio/msm8660: Fix wrong condition for VOIP sampling rate

- Mediaserver crash is observed during voice call setup
- VOIP sampling rate is wrongly checked and error is returned
  for valid sampling rate also
- Fix this problem by removing the wrong check for sampling rate
  Select WB mode for 16K sampling rate and return proper buffer
  size in bufferSize function

Change-Id: Iabc9d0c79fee99954097d41662070131fa51e7b4
CRs-Fixed: 395816
(cherry picked from commit 4039c7258f9f0735c943eafb850734fd6d35f02a)
(cherry picked from commit 5579d45bae575b3a99cdc44bc4154555afe77d9b)
audio/msm8660: Set proper device for Voip routing commands

-Voice message doesn't switch to earpiece when switched from speaker
in Fetion apk.
-Device routing commands to streamOutDirect session use primary
output stream device set. This results in ignoring the device set
for voip session. Fetion uses music stream to play on speaker and
voice stream to route to earpiece.
-Fix this problem by setting device routed for streamOutDirect by
explicitly sending the output device value set in setParameters.
Also if the requested device is the same as current device, still
allow routing call to AudioHardware as current outputDesc might not
be updated with current active device always. In such cases if device
stored in outputDesc is same as newDevice it will still not allow
routing from current device. Since there is already a check in
AudioHardware to avoid routing multiple calls on same device,
removing this check is safe.

Change-Id: I934f3fcc5d77ffdb7634ba471d1cfd38682c6a61
CRs-Fixed: 444787
audio/msm8660: Fix for improper LPA playback after seek

-LPA playback is not in continuous manner when rapid seek is performed
and effects is turned on/off.
-After seek, mSkipwrite flag is set to skip the current buffer either
in bufferavailable or write. If returned from write there is a
mismatch in buffer maintenance between flinger and hal as flinger
is not aware of buffer skip and has already pushed back the buffer
into mEffectsPool.
-Return error in skip case to handle in flinger and re-arrange buffers
to original state in mEffectsPool to avoid any mismatch.
Also mReachedEOS was getting set after fsync i.e. after write_done of
last buffer is processed and hence EOS was not getting posted to the
above layers. Moved this to ahead of fsync to avoid issues.

CRs-Fixed: 454460, 453872, 453833

(cherry picked from commit 8af44e4b795d289315188a3879a07596454bc923)

Change-Id: I98821fb0c97fdfc4f8d27e4480877ed963e5a61e
audio/msm8660: Fix LPA playback issue after continuous seek

- Playback is not continuous after multiple forward/backward seek
  operations.
- After flush buffers are not maintained in correct order, which
  is causing some old data to be heard after flush.
- Maintain correct order of empty buffers after flush.

Change-Id: I40df9fde9b0a6e39803a509be34f2b73ef722c35
CRs-Fixed: 440952
audio/msm8660: Fix native crash during rapid seek operations

- Native crashes are observed during rapid seek, next and previous
  song switch operations
- There is some race condition between write and flush which results
  in adding a buffer multiple times to empty queue. This tries to
  free the buffer multiple times during reset and results in native
  crash
- Fix this issue by adding proper mutex in write and flush calls
  which synchronizes these operations and avoids crashes

CRs-Fixed: 450172
(cherry picked from commit a4413c7646320169bca133d1e7b32598ed4baa02)

Change-Id: I530d4018b221b57ec325dbe40b670ef49007aaa9