Commit graph

78 commits

Author SHA1 Message Date
Eric Laurent
5a950c960c audio policy: reuse direct output when possible
Modified getOutput() logic to not systematically
open a new direct output when a profile matches a request.
This causes a problem when transitioning between two
multichannel tracks as the audio HAL will most of the times
only support one direct output stream open at a time.

Instead, reuse an open output if all the parameters match
or force close the output before reopening it.

Also modify releaseOuput():
- close a direct output only if no client is using it anymore
- call closeOutput() instead of removing the output from
the open output list: this factors in code executed when closing an
output stream.

Bug 8388941

Change-Id: Ic3d3beb21063622ddf57a5b932f93d56f2986f54
2013-04-04 14:18:40 -07:00
Eric Laurent
80f5b0400f audio policy: fix music glitch when starting call
When answering a call in silent mode, music playing over A2DP
was not immediately muted by current audio policy manager logic.

The fix consists in muting media strategy on all output streams
immediately when entering in call.

Also add methods to AudioOutputDescriptor to report
recent global, per strategy and per stream activity.

Bug 8315512

Change-Id: I4a90eb05db50e4f22374d02b1e647e8662f6bec6
2013-03-25 16:58:39 -07:00
Eric Laurent
9641bd36db audio policy: fix in call capture device
Allow use of default capture device when
AUDIO_SOURCE_VOICE_UPLINK is specified and the platform
does not support AUDIO_DEVICE_IN_VOICE_CALL.

Change-Id: Ibbc314f60c91e5a0fa75d57878f2d2a96ef2d83b
2013-03-05 16:53:53 +00:00
Eric Laurent
f32e38e24d audio policy: fix music glitch with touch sounds
There is a brief music interruption when a touch sound
is played the first time after the headset insertion.

This is due to a bug in audio policy manager logic to prevent
volume bursts while changing device while music is playing.

The fix consists in muting music only on current output stream
when changing device, not all output streams.

Also prevent unecessary device change if the requested device
is not supported by the output stream profile.

Bug: 8301565
Change-Id: I00daab19bbdda10ca856a05fa32a1e333e1b9469
2013-03-04 17:56:02 -08:00
Eric Laurent
bb0e0da128 Merge "audio policy: fix in call audio setup delay" 2013-02-11 21:42:48 +00:00
Eric Laurent
8bf56b16e5 audio policy: fix in call audio setup delay
There is a delay inserted by audio policy manager before switching
device when entering in call mode to allow music playback to be muted
before the device actually switches.

This delay can be significant when high latency outputs (e.g. deep buffers) are
present and should not be applied if the output is not active.

Issue 7612431.

Change-Id: I04b666769033dbfdc861752b030d3f7bdffe9435
2013-02-11 12:48:20 -08:00
Jean-Michel Trivi
dc3bf1a374 Identify remote stream activity, used for notification routing
Add support for checking remote stream activity.

Don't route notifications like media when media active remotely.

Add remote stream activity query in audio policy HAL.

Bug 7485803

Change-Id: Ifb722c7f9ffbfbdc877fec5156bcfc09bec40651
2013-02-11 10:23:13 -08:00
Eric Laurent
60758e27a4 audio policy: added front + back mic
Added definition to parse front + back mic from input descriptors
in audio_policy.conf file.

Change-Id: I9ebdeac664e12104589a52d15acbbfc4db787923
2013-01-22 17:07:33 -08:00
Eric Laurent
911408bc76 Merge "audio policy: fix notification start delay" 2012-11-08 09:43:16 -08:00
Jason Simmons
02580d804a am c8bc2286: am 7aab5b0f: Merge "Close a newly opened direct output if its parameters are invalid" into jb-mr1-aah-dev
* commit 'c8bc22869096ee413717102d3f5d0ca804cc3174':
  Close a newly opened direct output if its parameters are invalid
2012-11-08 06:18:52 -08:00
Eric Laurent
42fa8215a7 audio policy: fix notification start delay
The mechanism delaying notifications in case of
muliple active outputs with long latencies must
take into account recently paused audio tracks.

Bug 7400428.

Change-Id: I4ac9dfac81336e33f475b4f28df82713707d0c46
2012-11-07 13:48:47 -08:00
Jason Simmons
10705c404c Close a newly opened direct output if its parameters are invalid
Change-Id: I27ac015217480a854d25273ab9498949971b411a
2012-10-31 10:50:12 -07:00
Eric Laurent
2c72e9faa5 audio policy: fix volume change when disabling SCO
commit 76e97d39 introduced a regression by having setDeviceConnectionState()
force a device change on duplicated outputs even if the selected device is 0.
This also forces a device 0 for the two outputs it is duplicated to,
which may override a valid device selection on those outputs and apply
default volumes.

Bug 7429869.

Change-Id: I37dd66343c54eb27e420089edbda04444fa1e2c6
2012-10-30 16:14:04 -07:00
John Grossman
5debe92591 Fix a parse error in checkOutputForDevice
Fix a small parsing error in parsing the supported formats and sample
rates of a stream out with dynamic values for these parameters.  The
channel mask parser was properly skipping the "=" in the setting
string, but formats and sample rates were not (cauing the first
reported format and sample rate to end up being skipped)

Change-Id: Id227a44f6b5fc0c223f2ce74f94ebb6abc5fa77d
Signed-off-by: John Grossman <johngro@google.com>
2012-10-29 18:54:12 -07:00
Eric Laurent
5a484b753c audio policy: active analog dock force usage
Qualify the selection of the analog dock for media by the force use.

Bug 7302106.

Change-Id: I2ea48fd43866ce8491085bba72a27751b2203401
2012-10-26 18:04:03 -07:00
Eric Laurent
89ef58f4c0 Merge "audio policy: fix scanning of supported devices" into jb-mr1-dev 2012-10-18 11:38:54 -07:00
Eric Laurent
672e9ace42 Merge "audio policy: tune voice/video chat volumes" into jb-mr1-dev 2012-10-18 10:54:45 -07:00
Eric Laurent
fd8cecbee6 audio policy: fix scanning of supported devices
Fix is a bug in checkOutputsForDevice() which makes that we can
try to reopen an output stream after a new device is connected because
we believe that no opened output is available for this device.

Bug 7369475.

Change-Id: I2290a9b5ba102657cda495fbb8a995e0003b883a
2012-10-17 17:49:41 -07:00
Eric Laurent
0d6490a58b audio policy: tune voice/video chat volumes
Add new volume curves for VOICE_CALL stream type
to improve voice/video chat volume on speakers.

Bug 7346643.

Change-Id: Ib282a97570d2234deec6b58391bdfc45846d9cc0
2012-10-17 10:22:29 -07:00
SathishKumar Mani
772686310a audio policy: update output delayMs in setPhoneState
- Issue: When call is connected in HDMI while playing music,
  Playback is routed to phone shortly
- Cause: delayMs is not updated correctly, and no delay is
  set when setOutputDevice is called
- Fix: update delayMs with biggest mOutput latency and mute
  STRATEGY_MEDIA on all outputs

Bug: 7268860
Change-Id: I12b75443a29ab8485314bd0cbfe5ee4789be5c29
Signed-off-by: Iliyan Malchev <malchev@google.com>
2012-10-17 10:20:37 -07:00
Eric Laurent
aac673172c Merge "audio policy: do not route in call audio to HDMI" into jb-mr1-dev 2012-10-16 17:12:44 -07:00
Marco Nelissen
85ad78f27c Initialize mStrategyMutedByDevice
Valgrind found this

Change-Id: I24c640c2b0b6cac129c23bfc18828aff005ec952
2012-10-16 15:00:37 -07:00
Eric Laurent
b52f373bd5 audio policy: do not route in call audio to HDMI
In call audio shuold not be routed to HDMI, S/PDIF or USB
by default as most platform do not support it.

Bug 7339490.

Change-Id: Iac4803f3fbde0c321fc7b37ab7ba34af6a16b4aa
2012-10-16 14:59:36 -07:00
Jean-Michel Trivi
31363a9cb9 Remote audio submix always has priority for media, only plays media
Don't use force use mechanism for remote audio submix routing.

Prevent streams of strategy sonification to be played over
 remote audio submix (e.g. WFD) and HDMI

Bug 7318180

Change-Id: Ic5c87d3c568873dffea9002cf87ecf42b403cde6
2012-10-11 19:18:40 -07:00
Jean-Michel Trivi
abc55c6983 AudioPolicyManager supports querying active record sources
Add support for querying whether there is currently a recording
  underway from the specified audio source.

Bug 7314859

Change-Id: I8894845b176241134870af5df2bebc5ef27e4de4
2012-10-10 15:19:35 -07:00
Eric Laurent
738207def5 audio policy: add forced uses for system
The volume and routing policy of AUDIO_STREAM_ENFORCED_AUDIBLE is
now controlled by AudioService by means of new forced use type
AUDIO_POLICY_FORCE_FOR_SYSTEM with config
AUDIO_POLICY_FORCE_SYSTEM_ENFORCED.

Property ro.camera.sound.forced is not used anymore.

Bug 7032634.

Change-Id: I742b0eebbe6b013f61d199846454a06411b52bc8
2012-10-08 15:59:36 -07:00
Eric Laurent
76e97d3950 audio policy: force device update if disconnected
Force the new device selection to be applied when a device is disconnected
even if none is select. This is to indicate to the audio HAL that current
device selection is not valid anymore even if no new device is selected because
no audio track is active.

Bug 7141149.

Change-Id: Iade02fb53a4cc2051fce9da07870c5391396b696
2012-09-26 18:54:57 -07:00
Eric Laurent
be13d2ebd0 audio policy: fix crash when closing HDMI output
When a direct output is closed, the vector containing
the previously opened outputs must also be updated.

Bug 7157451.

Change-Id: I575b1f4928cf7527a4a98632fdec7600664a1e1c
2012-09-25 16:52:22 -07:00
Jean-Michel Trivi
6d3a115c09 Support audio recording while remote submix is active
When evaluating if an audio record is active, do not count inputs
 opened on "virtual" devices, such as remote submix, as active.

Change-Id: If19c321cf673e3bdf4c3f81e73c163190df7c21e
2012-09-18 12:21:14 -07:00
Eric Laurent
ed8f62d4fa audio: new audio devices enums
Changes for new audio devices enums:
- legacy audio HAL wrapper provides conversion between new and
old device enums. It exposes a rev 2.0 audio device API to the
audio framework and allow legacy implementation to use old device enums.
- AudioPolicyManager: use standard enum value for no device (0).

Change-Id: I855d72291d672cdd8a6641bedb228634a54b7d9d
2012-09-07 10:34:46 -07:00
Jean-Michel Trivi
48387b28c8 Update Audio Policy Manager for remote submix
Define a new forced mode to route media to remote submix.
Update media routing rules according to mode.
Modify device connection management for remote submix.

Note that this CL doesn't implement changes to not prevent audio
 recording when WFD is on, as audio recording is currently limited
 to one input.

Change-Id: I458fe1802705da2d091ff82e536dc3e7f092f291
2012-09-07 09:46:53 -07:00
Eric Laurent
17a73c3394 audio policy: fix ringtone volume on headphones
When limiting ringtone volume because headphones are connected
and music is playing, the volume was not limited against the right
music volume. The is because the device used for music (headphone)
is not the same as the one used for ringtone (headphone + speaker).

Bug 6816207.

Change-Id: I3342be1789a1b7c58705812335b788f030bc6d76
2012-09-05 18:13:06 -07:00
Jean-Michel Trivi
c8101f5b14 Update AudioPolicyManagerBase to only use audio_devices_t
The AudioPolicyManagerBase implementation was using some device
 enum values from AudioSystemLegacy.h, of type audio_devices,
 and some from /system/audio.h, of type audio_devices_t.
Now only uses audio_devices_t, and associated functions to
 inspect what audio device type they correspond to.
Added #define to represent "no audio device" to clarify code.
Removed unused variable in AudioPolicyManagerBase::startOutput()

Change-Id: Ibec311dac550d6a806397377206a43bc708914c0
2012-08-24 15:12:57 -07:00
Glenn Kasten
c94dccc97c effect_descriptor_t const correctness
Change-Id: I734155d4cebb22b180f25290332c7c48be1e2b36
2012-07-24 07:51:26 -07:00
Eric Laurent
c952527e6f audio policy: fix HDMI hot plug
When an HDMI sink is connected it is possible that
a direct output is made available for multichannel audio.
In this case, the list of outputs available to reach the HDMI device
after the connection is different from before. checkOutputForStrategy()
must take this into account in order to invalidate tracks so that
they can be re connected to the multi channel output if necessary.

Change-Id: Id0baeb51688eba8017fe96bf92aaac52eb8e0f59
2012-06-21 15:10:31 -07:00
Eric Laurent
4366b4a673 audio policy: fix volume upon A2DP connection
setForceUse() should not force new device selection on outputs
if the selected device is 0. If a device 0 (no device) selection
is forced on a duplicated output, this causes volumes to be reset to
their default on outputs the duplicated output is connected to.

Also force reapply volumes when a new output is created. It is safer and more
explicit than relying on the fact that the selected volume is different
from default volume and thus is actually sent to audioflinger.

Bug 6658021.

Change-Id: I0a14d5229847e001b0d44f60d41c241efdb9946a
2012-06-13 15:19:32 -07:00
Jean-Michel Trivi
e3ce4e9997 Merge "Increase system stream volume on speaker" into jb-dev 2012-06-07 15:29:10 -07:00
Eric Laurent
5568b826b6 Merge "audio policy: fix notification volume limitation" into jb-dev 2012-06-07 09:10:26 -07:00
Eric Laurent
ac3cf10ef6 audio policy: fix notification volume limitation
The limitation of notification volume when playing music over headphones
has been broken for devices where notifications and music are played over
separate output streams.

Fix computeVolume() to check music stream activity on all outputs.

Bug 6623707.

Change-Id: Ie25f9b428ea086efe0be5fea2d31551d2528b655
2012-06-06 17:39:16 -07:00
Eric Laurent
fa3697d716 audio policy: remove delay when enabling speaker
Do not force mute on a strategy when moving it from one output
stream to another if no stream is active.

Bug 6611972.

Change-Id: I21f72b0ef3600639de66e6b0a1c3ae44045fd81f
2012-06-06 16:58:35 -07:00
Jean-Michel Trivi
1238978744 Increase system stream volume on speaker
Increase the volume of the system stream for speaker output, so
 sounds played on this stream can be louder on devices that
 need it.
Additional changes in the rest of the framework will define properties
 to tune sound effect levels on a per-device basis.

Bug 6448481

Change-Id: Ia6c1ff314a321c6e271a682e3f4ff64c250b184e
2012-06-05 11:35:24 -07:00
Eric Laurent
3cdfddf1b2 audio policy: improve support for direct outputs
Add the capability to query supported parameters for
direct outputs after a device is connected. This allows
to dynamically update the output profile for devices like
HDMI where the capabilities depend on the connected sink.

Also added very verbose log mode for volume and mute.

Change-Id: I1d4ba8e7dbc3e1af883582857ce93240441e551c
2012-06-04 14:02:07 -07:00
Marco Nelissen
4660455366 Ensure global effects are on the correct output
Global effects such as the visualizer would sometimes not be on the
right output, for example when switching from a2dp to wired headset
or back, when there are both regular and deep buffer outputs available.
We now check which of the available outputs the global effect should
be on when more than one is available.
b/6528772

Change-Id: Ie268e32ef41e7888da67c24730dc93750a2cf579
2012-05-31 12:21:26 -07:00
Eric Laurent
1afd84f622 audio policy: allow disabling A2DP for media.
Added FORCE_NO_BT_A2DP forced use to allow applications to
override default policy to use A2DP whenever connected.

Bug 6485897.

Change-Id: I784271c062294fbe1aff7884965075b40c68dc24
2012-05-22 11:31:26 -07:00
Eric Laurent
01e6272f0a audio policy: fix in call volume problem.
When switching audio path, it is sometimes required
to temporarily mute certain streams to avoid glitches.
The unmute command is sent with a delay but the volume applied
when unmuting is computed according to the state at the time of mute.
If the device selection changes after the delayed unmute is programmed
the new volume will not correspond to the new device.

setStreamMute() now accepts a device selection as input parameter which is
used instead of current device for volume computation.

Bug 6497819.

Change-Id: I355ebf9e1afe814fa5c2723bda9c40e58f921b46
2012-05-15 19:26:46 -07:00
Eric Laurent
7465678e0d Reduce system stream volume.
Reduce system stream volume by 6dB as
UI sounds are now perceived as being too loud.

Issue 6448481.

Change-Id: I0237eb94245014724dfdf55253049340e2162af8
2012-05-10 10:12:19 -07:00
Eric Laurent
ddfe26905e system and UI sounds volume policy
Added specific volume curves for AUDIO_STREAM_SYSTEM,
AUDIO_STREAM_ENFORCED_AUDIBLE and AUDIO_STREAM_DTMF.
Volume for these streams tracks AUDIO_STREAM_RING on phones
and AUDIO_STREAM_MUSIC on tablets but is contrained in the range
-24dB to -6dB on speaker and -24dB to -12dB on headset.

STRATEGY_ENFORCED_AUDIBLE routing policy is now the same as
STRATEGY_MEDIA in countries where not enforced.

Change-Id: If58d96559bfe2bbff4cd94c631d5933bd940778e
2012-04-26 10:17:13 -07:00
Dima Zavin
739022f26a audio_policy: set some reasonable defaults if audio_policy.conf is not found
Change-Id: I25f7407c34b3032d4e77a27a4ac47b648098d9b0
Signed-off-by: Dima Zavin <dima@android.com>
2012-04-24 12:55:06 -07:00
Dima Zavin
5ec145df77 audio_policy: look for config file in /vendor first
Change-Id: If10308f688437e1682e4104120772cfce16e9d89
Signed-off-by: Dima Zavin <dima@android.com>
2012-04-23 16:51:00 -07:00
Eric Laurent
9029a4fe8a audio policy: volume burst when switching device
The addition of the per device volume feature has introduced
a problem where a volume burst can be heard in the headphones
just after insertion if the speaker volume is much higher than the
headphones volume.

Added a temporary mute of the output when switching device to force
volume ramp to 0 and back up to new volume.

Issue 5984108.

Change-Id: I5c9ffbbcadd12d25c78cc2614d351346b8186c55
2012-04-23 10:25:13 -07:00