audio/msm7x30: port forwarding HTC code from gb

Change-Id: I89f0ad806a77c1368e10495287f6693ecb9282ba
audio/msm7x30: perform null checks when calling libhtc_acoustic functions

Fixes null pointer dereference when msm72xx_set_audpre_params and
msm72xx_enable_audpre are called from libhtc_acoustic.so that does
not have those functions (such as those for msm8x60 platform).

Change-Id: Ifa4357835e938b374e09908c34c14c8c5c52ce10
audio/msm7x30: device enum debug

Change-Id: I3490e21b4177b9e30e6dea548728679001247fce
audio/msm7x30: set mRecordState in AudioInputStreamMSM72xx::set

This fixes audio input/recording, including voice dialer and
voice search.

Change-Id: Ica042715ffc7ee664507951f6f7591b23532c34c
audio/msm7x30: fix voice volume on first call

- Store float voice volume got from audioflinger even if
  msm_set_voice_rx_vol return an error and re-use it on next call.
- Remove redundant volume set.

Change-Id: I1653152d81add785f8a7eee148bf849fecacc841
audio/msm7x30: Change fallback route to speaker

* Add explict case for HANDSET, and use SPEAKER as fallback

Change-Id: Ie6dd33f9acb7fd8e5536220e8230822b534798da
audio/msm7x30: fix a crash on audio initialize

Fixes crash on mediaserver if the device_count got from
audioalsa library is greater than DEVICE_COUNT in HAL

Change-Id: Ic5a29ddbee4f7b79ec944e6b48ef8272177659e6
Revert "audio/8655: Enabling LPA playback by adding AudioSessionOutLPA class"

This hasn't worked on 7x30 since ICS, and it also requires ION which
most 7x30 devices can not use.

This reverts commit b982f5a7b665873688c6710d53b4f3902a4c2876.

Change-Id: If1f4ba6fbca611baca220e417a4ef5abd8c1c216
audio/msm7x30: #ifdef teh things

    BOARD_HAVE_QCOM_FM
    BOARD_USES_QCOM_AUDIO_LPA
    BOARD_USES_QCOM_AUDIO_SPEECH
    BOARD_USES_QCOM_AUDIO_VOIPMUTE
    BOARD_USES_QCOM_AUDIO_RESETALL
    WITH_QCOM_VOIP_OVER_MVS

Change-Id: Ia3965096d36768468808b8e3f2ff34318e6aec89
audio/msm7x30: fix for SEMC devices with stereo hw speaker

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>

Change-Id: I2a326b13101bfe589eebe46012559633d8b361df
alsa_sound: Fix for Tunnelplayer IOCTL drain block

-IOCTL drain was getting stuck when standby was
called after seeking to EOS
-This happens when seek was done to the
end of the stream which would lead to only
a zero length buffer being sent.
In this case, IOCTL drain will block forever
-To solve this, IOCTL drain was interrupted
by calling flush from the context of standby

CRs-Fixed: 467166

Change-Id: I0d119c362670fd4f99b023dd4a1fdebde7832c02
alsa_sound: set ALSADevice::mInChannels to 0 after voice call finishes

When a voice call is established, through  enableVoiceCall()
mInChannels is set to non-zero value, so during disableVoiceCall()
it should be reset to zero.

Change-Id: Ic3f39990c7e1820e5c61e063b8c84e160cdd20bb
CRs-Fixed: 467775
alsa_sound: Fix for audio loss on switching from BT to AOA

-When AOA is connected to device while playback is on BT, usb stream is
 created. The external out stream gets updated with usb stream even
 when a2dp stream is active.
-Update external out stream with a2dp or usb stream in openExtOut only
 if it does not refer to any other stream.

Change-Id: I625ee20ac91ef1be4b21e91fd5e9fffc54a08033
CRs-Fixed: 464457
alsa_sound: Patch to remove delay in second MT call during hold

-When voice call is on hold, when another MT call comes, the ringtone
 is delayed by 6sec.
-This is a special case for fusion, when the voice call is on hold and
 there is another incoming MT call, telephony will set MODE_IN_RINGTONE
 During this there is a change in device from Handset to Speaker,
 this is not propagated to MDM.
-Fix is to propagate device change to MDM during MODE_IN_RINGTONE
 if there is a call on hold already.

CRs-Fixed: 447560

Change-Id: Ia29729bc97a585bd45657e558d04374104e1ce9c
Change to handle A2dp suspend setparameter, which will suspend the thread

When A2dp suspend setparameter is called we were not suspending the thread.
We were suspending it only during stop. This will make sure we suspend the
thread even during the suspend setparameter call

CRs-Fixed: 415399
Change-Id: I49ae25fc028e9d4927fd3d3131c8f97f3e873fc1
alsa_sound: Fix corruption in recording over usb.

-Sometimes the hardware pointer for proxy driver is not updated for
 successive callbacks. This is because in the recording case proxy
 driver and usb driver runs at real time. This does not mandate
 that the data is read by proxy driver as soon as data is written
 from userspace. Any delay in getting dat from usb also can cause
 the issue.
-Fix is to increase the start threshold of proxy side for recording
 so that playback is not started without sufficient data.

Change-Id: I86384bfc96b8262309a1402ca9fe5744af3b436d
CRs-Fixed: 465317
hardware/qcom/audio: Fix for Crash during Gtalk startup

 -Crash is observed when Hangouts 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
(cherry picked from commit b9f1299e4ca8b96907f97914a0cf65fd5a3d3174)

Change-Id: I7ef3cf76394e1469db9d21a1484aacf1251c4f25
alsa_audio:remove the device from device list if open fails

-Opening second record session is failed,which is
expected but  after that user is no more able to
open record session
-The device is already got added in alsa_handle after
calling mALSADevice->open but if this open fails, need
to be deleted from device list.
-If mALSADevice->open is failed then erase the device from from
mDeviceList so that next time it can opened.

Change-Id: I9847f65718d8330292f312dffe18dfcb672f2d3d
alsa_sound: Increase delay in temp mute

-Silence for small time when headset is inserted
 and then touch tone is played.
-Stream is unmuted in checkDeviceMuteStrategies before
 device switch occurs.
-Increase delay in temp mute to ensure unmute after
 device switch.

CRs-Fixed: 470160
Change-Id: I6bc443abf77e5600675846086a57090f49bf9bd7
alsa_sound : Fix for audio routing speaker though BT is connected

- Speaker device is selected by getDeviceForStrategy() though BT is
  connected as mA2dpSuspended is still remaining as 'true' even
  after ending the voice call.
- This flag is not updated by checkA2dpSuspend() as force usage
  for communication and record is still FORCE_BT_SCO after ending
  voice call.
- Modified condition check to set mA2dpSuspended to 'false' as soon
  as phone state is changed to MODE_NORMAL

Change-Id: Ibc0d19b361755d8715c446401d2e14d914fd7020
CRs-Fixed: 464404