Commit Graph

160 Commits

Author SHA1 Message Date
Sharad Sangle c66b9ca876 policy-hal: make sure policy-hal is in sync with AOSP
This change makes sure that changes in the base function
 are moved to custom policy if the function is derived in
 custom policy.

 Below changes are taken care

1) audio policy: fix capture indication to sound trigger service.

   Only indicate active capture to sound trigger service
   when capturing from primay HW module.

   Bug: 31826453
   Bug: 31771879
   Change-Id: Idf92393d3e7dbf926b847ab23f670e7ab5dd5248

2) audio policy: fix media volume after ringtone

   Fix regression introduced by commit 11c499a5 causing
   music volume not to be restored after ringtone playback
   over duplicated output (speaker + A2DP).

   Bug: 31539910
   Change-Id: I1c4eebea1f1a8f82ae2acfeecb9a61c437a74e25

3) audio policy: fix call volume over USB

   Make sure the cache of output device selection per strategy is updated
   also when an input device is connected or disconnected as the list of
   input devices sometimes impacts the output device selection in
   getDeviceForStrategy().

   Bug: 30659619
   Change-Id: Ie9f7bafda0074afcc803f309379c35b538f50170

4) audio policy: workaround for truncated touch sounds

   Implement workaround to avoid touch sound truncation when
   audio path or volume changes are triggered by user actions.

   Also:
      - Fix regression introduced by commit c75307b7 causing failure
      to honor playback start delay in case of path change.
      - Fix failure to report path switch delay in updateCallRouting().
      - Make sure we delay temporary mute according to requested device
      switch delay in checkDeviceMuteStrategies().

   Bug: 29528161
   Bug: 27535199
   Change-Id: Id729579b6623ee67a767055b9aca7d2e2dde8491

Change-Id: I2f0b0e51ec725a462e913432f648cb7b3cf125fe
2017-01-19 00:25:52 -08:00
Sidipotu Ashok 738f19eb23 policy: avoid fallback to deep-buffer for fast requests
Avoid fallback to deep-buffer for outputs requested with fast
or raw flags.

Change-Id: I9b43f9065e59583ab84b954f2a87dbc8cc80cd16
2017-01-10 21:46:18 -08:00
Haynes Mathew George 2e4655ad2c policy_hal: Revert sound trigger changes related to device switch
Revert the synchronization fix handled in
Changed-Id: I9f1c4f82b84805b5f7a0aa770b333e7f2aeee21c
as it's already handled as part of upstream soundtrigger
AOSP refresh

CRs-Fixed: 1108103
Change-Id: I796230b2e1f5e02ed84e29eebc0e7d7be54c1842
2017-01-06 17:05:22 -08:00
Zhou Song 63f0b85b29 audio policy: reduce audio routing commands trafic
Restrict conditions under which we force a routing change
when an output becomes active to reduce the number of useless
binder calls, context switches and pausing of fast mixer thread.

Change-Id: Iab214fa92e0e829b2f609bd53b4731c862456fc0
CRs-Fixed: 1048593
2016-12-22 22:16:44 -08:00
Lalit Kansara 3391809f35 Compilation fix: N-MR1 merge
Change-Id: I24b0b4e9ed19552411b9042dd23ca244a7379377
2016-12-21 17:40:21 +05:30
Sharad Sangle 75170725fe policy-hal: Restrict trck offload for fractional sample rate
Restrict trck offload for fractional sample rate

Change-Id: I21ff697d90870040d800a19f0a776e855856aa8e
2016-12-19 06:21:01 -08:00
kunleiz 0b55ec76b0 hal: Fix VoIP ouput is closed if voice+voip concurrency is enabled
In APM, VoIP output would be closed even if Voice+VoIP concurrency
is enabled. This is due to FLAG_DIRECT is set for compress VoIP by
default. While direct output is forced to closed if Voice+Playback
concurrency is disabled.

Fix this by adding proper flag check to avoid VoIP output is
closed.

CRs-Fixed: 1087113
Change-Id: Idbfc1b499a1252f162300f4e1be4d27b44b7e95c
2016-11-24 05:22:29 -08:00
Ashish Jain 27564315c2 policy_hal: Fix check for direct pcm
-mediaplayer now opens a sink with DIRECT_PCM flag for eligible
playbacks, now if setPlayback rate api is triggered for
mediaplayer object,fall back to deep buffer output should happen.
But as the DIRECT_PCM flag is not removed from the requested flags,
the same direct output gets selected.
-Ensure that DIRECT_PCM flag is removed always if present,
before query for output, otherwise even when no direct output
is required, might end up with one.

Change-Id: Ie27e90851a0de4a6a6c2dc205a8ed9e281663626
2016-11-14 18:06:09 +05:30
Ashish Jain 771d02f056 policy_hal: Add support to identify direct pcm client.
-Update Direct pcm implementation to identify direct pcm client
as mediaplayer or app based audio track.
-This gives flexibility to disable direct pcm either of these clients.

Change-Id: Ief418a864a6f776c4dea7b2e953df9497cbcb5d0
2016-11-03 06:24:19 -07:00
Linux Build Service Account 10404ee2a4 Merge "Add Dolby cflags to policy_hal/Android.mk" 2016-11-03 00:47:24 -07:00
Linux Build Service Account 83e30923d1 Merge "audio: revert "remove 5.1 channel mask if SSR is not supported"" 2016-10-27 00:09:38 -07:00
Divya Narayanan Poojary 34dae9926a audio: revert "remove 5.1 channel mask if SSR is not supported"
Revert original change to "remove 5.1 channel mask if SSR is
not supported". Android N introduces index based channel
mask format which breaks this position channel mask logic.

Change-Id: I0e4fde87c23dbf1f9a1ad871259a312f366236e4
2016-10-19 16:01:02 -07:00
Preetam Singh Ranawat 3db94ecf89 policy_hal: Avoid invalidation of music stream if not required.
-APM tries to open output for all profiles supported on headphone
  device During insertion of headphone and invalidate music stream
  if number of output doesn't matches with outputs on previous device.
  Since DSD profile is supported on headphone device only, APM opens
  DSD output on headphone insertion and invalidate music stream.

 -Check if any of the new output is for DSD profile if number of output
  doesn't match on new device and prev device. Avoid invalidation if
  difference in outputs is because of DSD output.

Change-Id: I97092f620851b22a66a6f9cbfc9337db3828c5d6
2016-10-18 05:09:23 -07:00
Gao Jie 49345229fd Add Dolby cflags to policy_hal/Android.mk
Change-Id: I5e5bb6b8544f5d5822b235167bd7fc1df09a0c1c
(cherry picked from commit cfd6e4a8ce88e4822cac6d0f2ccf0c006a4185ef)
2016-10-18 05:03:01 -07:00
Preetam Singh Ranawat 96afc16c77 policy_hal: Native DSD concurrency with voice call.
-Native DSD playback is not supported concurrently with vocie call.

 -Reject offload request for DSD if voice call is in progress.
  Close DSD compress output for incoming voice call.

Change-Id: I5aae69e232db8d12f2492f0774984597ef06b610
2016-10-11 23:35:44 -07:00
Naresh Tanniru 11393709a7 audiopolicy: Avoid spurious routing in APM::stopSource
- On AudioOutput::stopSource, ignore routing calls
on an output descriptor to the same device

Change-Id: I10026d3d9147e45d3ed2b93160922bc3bb4bc2d0
2016-09-22 05:23:40 -07:00
Preetam Singh Ranawat 191eb77dd0 policy_hal: Add DSD format for duration check during offload request
-All DSD clips are being played over offload path on headset irrespecitve
  of clip duration.
 -Add DSD format as well for duration check during offload request.

Change-Id: Ib952c6de11c8e977275e7e5ee59eafd47a190cec
2016-09-09 17:13:56 +05:30
yidongh ae28e3a118 policy_hal: add bitrate restriction for wma/wma_pro/wma_lossless
HW decoded wma is wrong when bit rate of wma files is over specific
threshold, and noise can be heard when playing high bitrate wma files.

Check the bitrate of wma files when checking offload support, when
bit rate is too high, wma cannot be offloaded.

Change-Id: Ib477b9a9fc583caabfd738c620de345105a08988
CRs-Fixed: 1053169
2016-08-31 00:56:14 -07:00
Dhananjay Kumar cf558ba720 audiopolicy: remove soundcard status check from isOffloadSupported()
- Attempt to get sound card status from isOffloadSupported() can
  cause cross deadlock if audio flinger calls other audio policy
  APIs concurrently to update effect status with AudioFlinger's
  mLock already acquired.
- Also fetching sound card status from the context of
  isOffloadSupported() is not necessary as even though offload is
  marked supported here, error from request to open audio output
  would always make player fallback to non offload path.

CRs-Fixed: 1048043
Change-Id: I95cd3310da130deb1e6b3847bd6af79f15dd7415
2016-07-29 20:17:18 +05:30
Zhou Song bd0264ec06 audiopolicy: update correct device for primary output when FM resumed
When FM resumed after notification tone played, device updated for
primary output is still headset and speaker. This makes the device
to be switched back to headset and speaker after FM started on headset,
and temp mute can be applied for FM as new device changed from combo
device to headset when stopOutput() called for notificaton tone playback.

Update device for all outputs after FM started, and update the current
device of FM playback for primary output to avoid unnecessary temp mute.

Change-Id: I41badee6fb11e8c4574daa8042e38262a41b7735
CRs-Fixed: 1008864
2016-07-21 08:01:18 -07:00
Weiyin Jiang 6bba320b30 hal: correct offload tear down check due to sw effect
This is a subsidiary bug fix of the following incomplete one.

- audio: don't allow track offloaded if there's active sw effect
- Change-Id: Idf76374a3fd721eee595a8a9f6197a47a3c25e1c

CRs-Fixed: 984621
Change-Id: I8997f49560550d4174e1146340e0cd4d33957b24
2016-07-12 01:41:48 -07:00
Ashish Jain e4a22d5860 policy_hal: Move global effects to correct output
-With voice playback concurrency handling in place, offload or direct
outputs are force closed if a voice call is on.
-In such scenario, on closeOutput, global effects are moved to
primary output by audioflinger instead of deep buffer output
(mix output).
- When call ends, and playback resumes, movement of effects
from previous output to new output fails.
- Ensure that when a output is closed, effects if present
are moved to mix output, such that when a new output comes up
the effects can be moved from MIX output to the required output.

CRs-Fixed: 1030710
Change-Id: I127c02adff3f2148e318d9f4945c501f3f20dc55
2016-06-27 20:17:21 -07:00
Satya Krishna Pindiproli 8f83f10634 audiopolicy: add log to print XML policy config flag
Add a log message to print the value of the flag that
enables XML based audio policy configuration. This will
help in determining the actual policy configuration file
being loaded (whether XML or text based legacy config file).

Change-Id: I476cc16e89438709bdd6ceea371eed6bdb7b62f4
2016-06-25 13:20:55 -07:00
Ashish Jain 660d311f91 policy_hal : Ensure direct output is not selected again once rejected.
-Ensure once direct output is rejected, and the stream has
AUDIO_OUTPUT_FLAG_NONE and is not a music stream then primary output
should only be selected.

Change-Id: I0d01ba4c3e492fa0b78c4f5122a7c0ac5e830e9d
2016-06-22 02:14:01 -07:00
Zhou Song 2b3d155db6 audiopolicy: check active direct output before adding DIRECT_PCM flag
When getting new output with DIRECT_PCM flag set, the existing direct
pcm output can be closed and interrupted mutually with the requested one.
Don't add DIRECT_PCM flag if there's an active direct output for track
offload.

Change-Id: I250c9555dff2c17f94b57a14a1722bae00fe9f9b
CRs-Fixed: 986087
2016-06-14 06:08:19 -07:00
Ashish Jain ac510a7144 policy_hal: Enable Direct PCM for 24 bit PCM playback
-Pass correct bit width when creating a direct pcm output.
-Control 16 bit and 24 bit PCM offload request based on
properties.

Change-Id: I1d1c038acb6fd97a228df098383710eb4d27794d
2016-05-25 11:26:28 +05:30
Lalit Kansara f803ac57ec audiopolicy: fix compilation issue due to AOSP refresh
Edit function signature of startSource() to reflect changes
as per the latest AOSP refresh.

Change-Id: I5d56fa40e8ade8ddb6cb1fd1b801ad868e4ebe59
2016-05-17 08:39:52 +05:30
Ashish Jain 5fe12412eb policy_hal: Update policy hal with latest AOSP refresh.
This change updates policy HAL with latest AOSP refresh.

AudioPolicyManager: remove unnecessary device reconnection
Change-Id: I2182b205c2b72cebff657a7bbee95df97f97eb55

audio policy: fix HW A/V sync rerouting
Change-Id: I1f080232e439a410ded25ca8e461113a96687a3b

Dynamic policies: support for device selection
Change-Id: I71584081e7f1b2b5252fb6c4659fdeb464f7d282

Change-Id: I8e2812f1386aa7349f4470f25bf67ce88982ab74
2016-04-19 17:04:15 +05:30
Ashish Jain 630c5e1127 Revert "Bug fixing for AOSP refresh."
This reverts commit cb5fc31693.

Change-Id: Ic380f88784ad3f70b74b48d0baefca56353440c7
2016-04-19 17:04:02 +05:30
Vara Prasad A V S G cb5fc31693 Bug fixing for AOSP refresh.
Change-Id: Ie4b89db6663832e3b992e492fb5dcee0d0bc539d
2016-04-14 14:46:00 -07:00
Naveen Kumar 2cb8635f9e Merge commit '0110e267d11ed5aa7a64a306771e71aeb289db6a' into remote
Conflicts:
	policy_hal/AudioPolicyManager.cpp

Change-Id: Ia056c051af478e9853a05fea0ee2c8c7eca0670a
2016-04-13 03:30:28 +05:30
Ashish Jain 40cab3a33e policy-hal: enable custom audio policy
-This change enable custom audio policy and also includes
the fixes that went in to audio policy manager.

audio policy: add support for external audio sources
Change-Id: If5805d58a4356b2f681f1aabf54375f62b55b98a

Add setMasterMono and getMasterMono
Change-Id: I32dc1fcecf285967a61bd508af3bb299595db57d

AudioPolicy: AudioOutputDescriptor set/get for patch handle
Change-Id: I5bffecf7a157ec042d749064208bc6c279008542

AudioPolicyManager: force encoded surround setting
Change-Id: I0f7a486bf1aa7a27f15cf220e2c75ef23f8f8536

audio: several fixes in audio routing callbacks
Change-Id: Ieb0d9f92f563a40552eb31bc0499c8ac65f78ce4

audio policy: move volume table to XML file
Change-Id: I78c91bc3378b6c47202abe7b5c1c1e011ff62eed

AudioPolicy: capture sample rate 0 is route-specific default
Change-Id: I7d193640572c08ab5e5f1ecfc8ad6d31635967dd

audio policy: remove deserialization from policy objects
Change-Id: I1ce798848f4657b37e47446c9fbdc63f7ed0390e

DO NOT MERGE - audio policy: disable concurrent capture
Change-Id: I9085918f1f7b12e28430958cceb768bb29c12bdb

audio policy: select output with best sample format match
Change-Id: I31981940be5d1c06d713d52187cfb0a7bf355773

audio policy: audio sessions on input descriptors
Change-Id: I915a65989a7fd0d3cbe2fcf5a0aee2ea0df5f4f5

Call SoundTrigger::setCaptureState in AudioPoilcyManager::closeAllInputs
Change-Id: I613434ecacce3ef03a657008fd94c314948ba2b8

Change-Id: Iee8ef2647691fe1167b95f19357f17c28f54bf0e
2016-03-29 17:27:13 +05:30
Shiv Maliyappanahalli d77d3b3ce7 policy_hal: add support for 32/48KHz support for voip
Allow voip applications with 32/48KHz route to voice path
as the voip driver supports 32/48KHz.

Change-Id: If4537f5893e29e7e575278907f35e17ba986150e
2016-03-16 08:19:57 -07:00
Mingming Yin 60cd76498d audio: port sound trigger fixes
Port missing sound trigger fixes from default policy manager.

Change-Id: I00bb6a7365a324d139d5761dcc7803a8af307c13
CRs-fixed: 975739
2016-03-10 22:43:01 -08:00
Linux Build Service Account daf60b0497 Merge "hal: Fix warnings in audio HAL and policy" into av-userspace.lnx.1.0-dev.1.0 2016-03-08 22:09:08 -08:00
Alexy Joseph b13799480b hal: Fix warnings in audio HAL and policy
Enable Wall and Werror and fix warnings in
HAL and policy manager

CRs-Fixed: 962049

Change-Id: Ie93c8f933943875ac68e8318d777602ed864f531
2016-03-08 04:50:17 -08:00
Weiyin Jiang 31eefec89b hal: correct offload tear down check due to sw effect
This is a subsidiary bug fix of the following incomplete one.

- audio: don't allow track offloaded if there's active sw effect
- Change-Id: Idf76374a3fd721eee595a8a9f6197a47a3c25e1c

CRs-Fixed: 984621
Change-Id: I8997f49560550d4174e1146340e0cd4d33957b24
2016-03-08 04:25:56 -08:00
Zhou Song 58081b664a audiopolicy: fix notification tone during call not stopped after call ended
Due to wrong func isInCall() called in setPhoneState() after phone state
changed, notification tone won't be stopped after call ended.
Correct the func to isStateInCall(int state).

Change-Id: I607e96f1fecdcf37d8865af2aa9b4cbd4450aca6
CRs-Fixed: 978534
2016-03-04 00:26:10 -08:00
Satya Krishna Pindiproli fccb9153f3 audiopolicy: do not set FM volume during device connection/disconnection
Volume inconsistencies are observed when a headset is
plugged in and out repeatedly while FM is active.

This is because the volume stored for stream music for the primary
output is first applied and then the FM volume for headset is applied.

Do not set volume as part of headset connection/disconnection to fix
the issue as it gets set as part of setOutputDevice anyway.

CRs-Fixed: 978396
Change-Id: Ibe0f3639ac4825330a710e86abc31d609136c924
2016-02-26 17:06:38 +05:30
Weiyin Jiang cd327f89ea hal: don't allow track offload if there's active sw effect
Incorrect condition check causes direct output still being chosen even
if there's none offload effect enabled. Hence, sw only effect
implementation is bypassed and won't work.

Don't allow track offload if there's active sw effect.

CRs-Fixed: 979125
Change-Id: I79d54581f4347475d347f164b6471744c1301032
2016-02-22 21:52:05 -08:00
Weiyin Jiang d211ef5bc3 policy_hal: handle incall sonification without checking output refCount
Call handleIncallSonification in startSource and stopSource without
checking mRefCount to make sure ringtone mute/unmute is called for
multiple active stream.

Change-Id: I52290f9ae09dff3619ac3a36c8969da6c07853ec
CRs-Fixed: 972582
2016-02-16 17:50:58 -08:00
Mingming Yin 2dd77c273b policy_hal: fix for FM playback without active music stream
- Increase primary output ref count before getting new device
- This prevents to use NULL device for FM playback.

Change-Id: Idd2b36dab1990cdc1c1f603c5bdfd53b53c5c311
CRs-Fixed: 957807
2016-01-25 07:17:15 -08:00
Haynes Mathew George 603ae9b02d policy: Delay FM volume update to start of FM playback
Delay update of FM volume to start of FM playback.
This avoids unnecessary set_parameter calls on primary output
whenever volume changes on primary output. Unnecessary calls
on primary output can cause breaks in audio since FastMixer
will be put to HOT_IDLE more often

CRs-Fixed: 948361
Change-Id: Id614d32df7f35ac93dd029a08b10e19f64ac631e
2016-01-25 01:16:32 -08:00
Mingming Yin 1433cc64e2 policy_hal: fix for volume burst during FM device switch
- Issue: Volume burst is heard during device switch
  (headphone and speaker) for FM playback
- Root cause: delayMs passed to CheckAndSetVolume is
  not applied for FM playback
- Fix: Double delayMs and apply FM volume with this delay

Change-Id: Ifa0b214d16527973277a5c84b8a4f3fbd0760d07
2016-01-21 02:09:18 -08:00
Haynes Mathew George 0b2c37785b policy: Avoid unnecessary set_parameter calls
APM calls a set_parameter on primary output with key fm_volume
whenever a checkAndSetVolume is called. This is done irrespective
of whether the volume values are same of different.

A side effect of doing so is that the FastMixer associated with
the MixerThread will be put into HOT_IDLE unnecessarily which in turn
can cause glitches/breaks in audio.

CRs-Fixed: 948361
Change-Id: I7fd8b7340e6c78ee6d00b41ccf679582338c011a
2016-01-12 22:05:53 -08:00
vivek mehta c984b990b7 libaudiopolicymanager: DirectPCM: fix 44.1 clip playing noisy issue
- adding both deepbuffer and direct pcm is causing issue where wrong
  config is set to ADM
- add deepbuffer flag when fail to get direct output if deepbuffer
  was forced

Change-Id: I3bd65002c7a8895d461df257111faf22101cbe30
2016-01-05 18:42:45 -08:00
Dhananjay Kumar 9125b2a775 policy_hal: fix improper voice-playback concurrency handling
- setPhoneState checks call-state in audio hal to filter out
  unworthy usage of this API.
- With M upgrade, change to update call-state with audio hal is
  removed, instead permission checks are introduced to prevent
  random usage of such APIs. But setPhoneState is still checking
  for this call-state causing improper concurrency handling.
- Fix the issue by removing state check from setPhoneState.
- Remove set and get for parameter "in_call" from voice_extn.

Change-Id: I92fe10c617d6158976a0e07eed3275acb0aadd15
2015-12-14 04:31:19 -08:00
Preetam Singh Ranawat 61716b1bcc Merge 9c4ba54b3e on remote branch
Change-Id: I5a80c57243eda5a4fdd98a233766cd622b4ef9a3
2015-12-14 11:55:32 +05:30
Karthik Reddy Katta 3fb9be73a4 audio: update flags for selection of VoIP direct output
Ringtone mute is observed in LINE app MT call over BT headset.
VoIP direct output isn't returned due to incorrect flags update.
Primary output is returned even though the FLAG_DIRECT is set,
this in turn causing issues when renderer queries for getPosition(),
which is resulting in mute. Fix this by updating flags, so that
track gets VoIP direct output in this scenario.

Change-Id: I6d570ae6ed9e0a7506cb29be5b41687417b7d221
CRs-Fixed: 893558
2015-12-08 03:10:43 -08:00
Gao Jie db05783efb Merge DAX2 changes
Change-Id: If6fcfdef0b051f9015c127bdd7d28e3668e47435
 (cherry picked from commit 4879ebb6d14558695044be0a22a89fc8b7ac24ec)

Change-Id: I5ecf6c792bf1d5c481879a38231acfdb2a3ccc3e
2015-11-17 14:34:29 -08:00