Commit graph

108 commits

Author SHA1 Message Date
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
Eric Laurent
b2971bf2ae audio policy: add support for deep audio buffers
Added definitions for parsing deep buffer flags in output profiles.

Make sure that sound start is delayed enough to allow
duck/mute effect to apply before starting a notification on an output
with lower latency.

Change-Id: I1578e245da19d1a0f9ec62a2ea6dddaf82ea282b
2012-04-20 13:51:53 -07:00
Eric Laurent
0977cf534f rename audio policy flags
Change-Id: Ic42eba3432671f651c9703a07fe7b429a8ec0dff
2012-04-18 10:42:04 -07:00
Eric Laurent
599a1fc115 audio policy: added rules for USB audio devices
Change-Id: If712b0c7fcf281d66d34614529f3433e56e058fb
2012-04-06 16:28:09 -07:00
Jean-Michel Trivi
9f1f9b509c Allow non-direct output of any channel mask
Because of the downmix capability of the mixer, do not prevent
 a non-direct output to be retrieved based on channel mask.

Change-Id: I911f95f4055c2134298c233d14f2f5d586091fd4
2012-04-05 12:17:01 -07:00
Eric Laurent
70c236c929 audio policy: load audio hw modules
Audio hw modules are now loaded according to configuration
data read from audio_policy.conf. They are not loaded anymore
from a hardcoded list in AudiFlinger.

Output and input streams are opened on the hw module by which
they are exposed.

Also removed obsolete "acoustics" flags for input streams.

Change-Id: I8dc658cc83890d3ac7d5e36c372a03732aa5b0c4
2012-04-03 20:49:35 -07:00
Eric Laurent
5ccdf14a85 audio policy: use configuration file
The audio policy manager implementation now reads a configuration file at
boot time that contains descriptors for available audio hardware
modules and for each module the profiles of available inputs and outputs streams.

The configuration file path on the target is: /system/etc/audio_policy.conf.
A default configuration file is given that defines a basic configuration
with one primary audio hw module capable of playback and capture.
Each platform or device should have its own audio_policy.conf file.

Also removed default value of fromCache argument of getDeviceForStrategy()
and getNewDevice() methods.

Change-Id: I0c773d2331508bbc787f89b123dd6a7b8c10d459
2012-04-03 15:56:30 -07:00
Jean-Michel Trivi
12bd6e4a5c Only duplicate notifications when no media is playing
Map the NOTIFICATION stream type to a new strategy,
 named STRATEGY_NOTIFICATION_RESPECTFUL, which differs
 from STRATEGY_NOTIFICATION in that, when media is
 playing, the notifications will use the same output
 as the MEDIA strategy. This will results in the
 notifications not being duplicated on the speaker
 when a headset is in use for media playback.

Change-Id: I032be0e2d383c69b5b6c912d7174753f5572c4b4
2012-04-02 09:31:09 -07:00
Eric Laurent
f9a4e2eccf audio policy: use audio_devices_t when appropriate
Change-Id: I0b4e2ff705fce96b40fdda28b1bc4b514438bec6
2012-03-08 13:41:38 -08:00
Eric Laurent
08b014d9e5 audio policy: use common string for A2DP address
Use definition from audio.h for A2DP sink address parameter.

Change-Id: I2d7905b8e3dd71fab2efc68ae16682e09c3f872e
2012-03-07 19:04:55 -08:00
Eric Laurent
b4696fc22b audio policy manager: more generic A2DP impl.
This change makes support for A2DP related audio policy more generic:
-removed WITH_A2DP compilation switch
-use output profile descriptors listing the parameters
(sampling rate, format...) devices and attributes (low power, tunneling...)
for each available output.
All the behavior specific to A2DP is derived from the A2DP output profile
descriptor.
- removed obsolete a2dpUsedForSonification() method.

This is a first step towards a more generic support for different audio
hardware modules (USB, HDMI) and output streams supporting different
combinations of parameters (sampling rate, format...) and attributes
(low power, tunneling...).
Ultimately, the hw modules and output descriptors will loaded from a
configuration file.

Change-Id: Ife3e49e1afbcb72613bfc8ce38919bb087ca85ea
2012-03-07 17:53:49 -08:00
Eric Laurent
c5eb8b4a5d Fix volume not restored when exiting silent mode
The change for volume per device introduced a problem where if a headset
is plugged in while in silent mode, the sound will not be restored
at the first press on volume up key but only at the second press.

This is because when exiting silent mode, AudioService reapplies the
last known volume for all devices in any order and the last volume
applied prevails, even if it is for a device other than currently selected
by audio policy manager.

The fix consists in applying a new volume only if the device indicated
matches currently selected device on an output.

Change-Id: I778b90a9ec5a8b4a15e0333bd045f2dd327f388c
2012-02-15 18:40:31 -08:00
Glenn Kasten
70eb9dec50 Use audio_in_acoustics_t consistently
Change-Id: I9875afdf21937c88a5decc9d94e89fddffc3519e
2012-01-27 13:04:19 -08:00
Glenn Kasten
ca0657a1ca Audio policy HAL set_ringer_mode is deprecated
Change-Id: I66ef40ed381151ba61debe20edaa53bece0cc139
2012-01-18 15:24:50 -08:00
Eric Laurent
c6f331b3f4 audio policy manager: stream volume per device
Improve volume management by keeping track of volume for each type
of device independently.

AudioPolicyManagerBase now keeps track of stream volumes for each device
and apply volume according to current device selection.
Methods to set and get stream volume now specify the device class.
A value for "default" device is always present for each stream and is used
if a device is selected and no specific volume was ever set for this device.

Change-Id: I06d8f43aa151a09014f7e47e81304c73ff82e9f8
2012-01-17 16:00:01 -08:00
Steve Block
5efbd421e0 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Idfcd2f2269080d92a621dc432c65f7cf244588af
2012-01-08 10:18:02 +00:00
Steve Block
64cca04dcb Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I86e4ce26d8fba68584d0a7fc17111b53c56d2932
2012-01-05 23:27:53 +00:00
Eric Laurent
314bacacbb audio policy manager: remove ringer mode dump
The ringer mode is at the moment not passed down from AudioService to
AudioPolicyManager as it is currently not used in any routig decision.

So the value store in audio policy manager is wrong and the dump is miss leading.

Change-Id: I3c21c168393470fd64c1b73e3c511576a9acdd7e
2011-12-08 11:47:29 -08:00
Eric Laurent
c720e569d2 am c16ac09f: Force camera shutter sound to speaker in Japan.
* commit 'c16ac09f510437e8340be691720177a490ae78f0':
  Force camera shutter sound to speaker in Japan.
2011-11-02 17:31:48 +00:00
Eric Laurent
c16ac09f51 Force camera shutter sound to speaker in Japan.
Make sure that camera shutter sound is output to device speaker also while
in call.
Added a new strategy for enforced audible stream to address this case as
the routing policy is now different from sonification strategy.

Issue 5548406.

Change-Id: I2de39dfaef7d90e3804b238b1379f0f59b75e985
2011-11-01 13:54:26 -07:00
Steve Block
6a70518b93 Rename LOGV(_IF) to ALOGV(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I953e5eabaf5023a4dcd76339c336d9132f257f8c
2011-10-25 18:16:13 +01:00
Eric Laurent
497fb45662 Fix music heard in speaker before notifications.
Increase the delay after muting music when switching audio path
to both speaker and headset for notifications and ringtones.
This is required to avoid a residual of music to be output to speaker
now that the max latency has been increased in low power playback mode.

This is a temporary workaround that will be removed when low power mode
is controlled policy manager.

Change-Id: If08e7f46e499be362badb2a24a79d1723ebfc00a
2011-10-20 09:17:04 -07:00
Eric Laurent
e43c5c4ca4 Fix issue 5440852: Youtube volume is too small ...
When no DRC is applied by the platform when playing
over the device speaker, faint audio signals are not boosted and
barely audible until the media volume is raised to about one fourth
of the range.

Compensate this by applying a different volume curve for music stream
when the speaker is selected.

Change-Id: I03f316fb28150eda50b05dfa12310701e2674648
2011-10-18 18:29:26 -07:00
Eric Laurent
cd057ad277 Issue 5256795: Phone ringtone volume is too low
Modified the volume curve for ringtones and notifications
in audio policy manager. The first volume step now corresponds to
-30dB instead of -50dB thus making ringtone much more
audible for low volume settings.

Also made a generic implementation of volume curves according to
audio policy strategies.

Change-Id: Ieb7916ba2e53c2a10a47efec82814cabed21c48b
2011-09-12 17:01:15 -07:00
Eric Laurent
55ac23bc11 audio policy manager: invert SPDIF/HDMI priority
Route media audio in priority to S/PDIF output when available
even if HDMI is connected. This allows users to chose to output audio
to a different system than the display.

Also force media volume to max when playing over S/PDIF.

Change-Id: I03b82a7235cb60f2b5d6cf7923570554b07ac400
2011-09-12 12:40:35 -07:00
Eric Laurent
582a15744b AudioPolicyManager: register effect CPU on enable
Audio effect CPU usage is now registered on enable and
unregistered on disable instead of when the effect is
created or destroyed.

Change-Id: Icffcede9558d8d41887278f0efef2df430927381
2011-08-11 09:17:07 -07:00
Eric Laurent
1c65a49da0 Audio effects: support for audio pre processing
Audio policy manager: allow registration of audio effects on
inputs too.

Change-Id: I92efa5b51cfde591052a5c56ba2b0b84de80df0f
2011-07-12 17:19:08 -07:00
Dima Zavin
e81531e91e hardware_legacy: provide HAL helpers for legacy audio users
This doesn't actually create a HAL, but rather a set of helper static
libraries that device specific libraries (i.e. the old libaudio pieces)
can link against to create a proper audio HAL module.

We provide an audio_policy static wrapper and audio hardware interface
static wrapper.

Change-Id: Ie56195447ad24b83888f752dca24674b0afd8a76
Signed-off-by: Dima Zavin <dima@android.com>
2011-04-27 10:48:25 -07:00
Dima Zavin
f01215993d legacy: move legacy audio code from frameworks/base here
Change-Id: Ic5da0130af44354dffdf85c30cd99f57c6ee163c
Signed-off-by: Dima Zavin <dima@android.com>
2011-04-27 10:48:20 -07:00