78 Commits

Author SHA1 Message Date
Jean-Michel Trivi
191ff092b8 Fix bug 3376700 Volume too loud at lowest setting
Change volume attenuation curve to provide more attenuation at
 low volume settings, and finer steps at high volume.
See bug entry for link to doc with curve values.

Change-Id: I750548b2161a4c550ef982ba793156e4518119e8
2011-02-27 16:41:21 -08:00
Eric Laurent
d0545f5334 Fix issue 3400751.
Add a delay before restoring output path when a notification ends so that
short sounds can be heard on proper device before the path is actualy switched.

Change-Id: I1d2dd8e7e28e15fbcab344256f88499b26297372
2011-02-11 14:53:23 -08:00
Eric Laurent
eab7b0bbb4 Merge "Fix issue 3425342." 2011-02-11 14:48:20 -08:00
Eric Laurent
ee5d4b8fc4 Fix issue 3425342.
Change the device selection order as follows to enable easier use of
A2DP while the device is docked:
1 - wired Headset
2 - A2DP Headset
3 - SPDIF/HDMI
4 - Dock

Also do not limit notifications volume when on dock.

Change-Id: I55ea6bea9f2d9ff284b54023e541b2788d0f1eb8
2011-02-11 14:42:13 -08:00
Glenn Kasten
8b4b97a14a Bug 3352047 Wrong message when adjusting volume
Add hidden AudioManager.getDevicesForStream and output device codes.

Change-Id: I4d1c1d3b6a077cd117720817d1f733dda557b947
2011-02-10 14:37:42 -08:00
Brad Fitzpatrick
987cc804bd am be806fe8: am cc8f87e9: am f664d6f9: am b083d3b8: Merge "Initialize resampling buffer per track."
* commit 'be806fe8c1c7bb3ae70ae27dce41d672410af26a':
  Initialize resampling buffer per track.
2011-02-07 13:44:12 -08:00
Glenn Kasten
7e54397b8f Merge "Bug 3366668 Use BinderService template" 2011-02-04 14:00:17 -08:00
Brad Fitzpatrick
be806fe8c1 am cc8f87e9: am f664d6f9: am b083d3b8: Merge "Initialize resampling buffer per track."
* commit 'cc8f87e9410dd4de9a2fda4738429e6c6087c789':
  Initialize resampling buffer per track.
2011-02-04 10:32:50 -08:00
Brad Fitzpatrick
f664d6f916 am b083d3b8: Merge "Initialize resampling buffer per track."
* commit 'b083d3b816378ef3b9dceb33b2c2e20510b2632b':
  Initialize resampling buffer per track.
2011-02-04 10:27:54 -08:00
Yuuhi Yamaguchi
681d818523 Initialize resampling buffer per track.
When resampling too short sound, AudioMixer uses previous
tracks buffer. So we re-initialize the temporary buffer per
loop to avoid it.

Change-Id: I55a59a3b14faa8445e09c450478fe79cef704760
2011-02-04 15:24:34 +01:00
Glenn Kasten
8adacd8e22 Merge "Bug 3366885 Remove LVMX switch" 2011-02-03 18:44:32 -08:00
Eric Laurent
2e8fbebff4 am 6f1bd261: am 9c0a1003: Merge "Fix issue 3371080" into honeycomb
* commit '6f1bd261b7fd86ac7817ca061dfb55b95150b836':
  Fix issue 3371080
2011-02-03 17:18:46 -08:00
Glenn Kasten
1570aff60f Bug 3366885 Remove LVMX switch
Change-Id: I0bf98c6f85f00b3296874571e1c049dcc4e2fcca
2011-02-03 17:18:19 -08:00
Glenn Kasten
3515a33599 Bug 3366668 Use BinderService template
Change-Id: I93d7f3fc9dc9b6a365723d8a51a73a5aabdb4f93
2011-02-03 17:05:22 -08:00
Eric Laurent
25101b0b9a Fix issue 3371080
Modified default volume control logic in AudioService:
1 IN_CALL volume if in video/audio chat
2 NOTIFICATION if notification is playing or was playing less than 5s ago.
3 MUSIC

Modified silent mode:
- now also affect MUSIC stream type
- entering silent mode when VOL- hard key is pressed once while selected
stream volume is already at 0 (except for VOICE_CALL stream).
- exiting silent mode when pressing VOL+ hard key while in silent mode

Play sound FX (audible selections, keyboard clicks) at a fixed volume.

Modified audio framework:
- isStreamActive() method now implemented in AudioPolicyManagerBase (previously AudioFlinger)
- iStreamActive() now specifies a time window during which the stream is considered
active after it actually stopped.

Change-Id: I7e5a0724099450b9fc90825224180ac97322785f
2011-02-03 09:26:24 -08:00
Jean-Baptiste Queru
80838d256d Merge 0ef57993 from gingerbread
Change-Id: If10fee1ae387a8130356dd62fe678495402d5edf
2011-01-29 11:04:41 -08:00
Jean-Baptiste Queru
b7a6563d17 am 4eeb1047: Merge 13212f83 from gingerbread-plus-aosp
* commit '4eeb10470ffafe8c508027f363ac66b58da5bf00':
  Fix issue 2988031.
2011-01-29 08:57:47 -08:00
Jean-Baptiste Queru
4eeb10470f Merge 13212f83 from gingerbread-plus-aosp
Change-Id: I9a8ee0c7e7896aea85e7a7c18ee82927091cb670
2011-01-29 08:54:06 -08:00
Eric Laurent
111df679af Fix issue 2988031.
Limit SYSTEM stream volume when a headset is connected and music is playing.

Change-Id: Ieb44ae5bb53ffa9cd5fe8e317798eed279b78df8
2011-01-27 11:32:34 -08:00
Jean-Michel Trivi
2ba92c71b5 do not merge bug 3370834 Cherrypick from master
Cherripick from master CL 79833, 79417, 78864, 80332, 87500

Add new audio mode and recording source for audio communications
 other than telelphony.

The audio mode MODE_IN_CALL signals the system the device a phone
 call is currently underway. There was no way for audio video
 chat or VoIP applications to signal a call is underway, but not
 using the telephony resources. This change introduces a new mode
 to address this. Changes in other parts of the system (java
 and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
 state variable directly, but to use two new convenience methods,
 isInCall() and isStateInCall(int) instead.

Add a recording source used to designate a recording stream for
voice communications such as VoIP.

Update the platform-independent audio policy manager to pass the
 nature of the audio recording source to the audio policy client
 interface through the AudioPolicyClientInterface::setParameters()
 method.

SIP calls should set the audio mode to MODE_IN_COMMUNICATION,
 Audio mode MODE_IN_CALL is reserved for telephony.

SIP: Enable built-in echo canceler if available.
1. Always initialize AudioRecord with VOICE_COMMUNICATION.
2. If echo canceler is available, disable our echo suppressor.

Note that this CL is intentionally not correcting the
 getAudioSourceMax() return value in MediaRecorder.java as the
 new source is hidden here.

Change-Id: Ie68cd03c50553101aa2ad838fe9459b2cf151bc8
2011-01-26 11:20:01 -08:00
Jean-Michel Trivi
3aab0583d9 Bug 3376700 Add support in APM for stream-specific volume curves
The stream volume was handled the same way for all different stream,
 the only potential difference between each of them being the number
 of steps available to the user to change the volume. This was
 mapped to 99 steps of 0.5dB amplitude, offering a maximum attenuation
 of -49.5dB.
This change consists in defining for each stream a curve with two
 knees (3 segments) for conversion from volume index to attenuation.
 This curve is defined in the AudioPolicyManager in
 initializeVolumeCurves(), and can therefore be overridden by the
 platform.
Note that this change doesn't modify the volume curves: this CL
 enables the curves to be changed by overriding this default
 behavior.

Change-Id: I575b66799c52df2906db248943b15120b8a79ea2
2011-01-25 10:04:31 -08:00
Eric Laurent
ab1fe306ae do not merge - Fix issue 3371096.
EffectModule::process() was copying effect chain input buffer to
output buffer if no effect was active instead of accumulating it.

Change-Id: If4ca75601ea69a088d0f71d88aec53e90a1dec89
2011-01-20 12:05:25 -08:00
Eric Laurent
67b5ed31ed Fix issue 3371096.
EffectModule::process() was copying effect chain input buffer to
output buffer if no effect was active instead of accumulating it.

Change-Id: I2838af2e7b6654d0a76547625929a5453da68d02
2011-01-19 18:36:13 -08:00
Eric Laurent
0163594301 Tentative fix for issue 3362362.
The problem is likely that one method is called on the AudioPolicyManagerBase
instance while it is still being constructed by AudioPolicyService.

To avoid this, the AudioPolicyService mutex is held by the constructor until the
platform specific AudioPolicyManager is constructed and the member
mpPolicyManager initialized.

Also added an initCheck() method to AudioPolicyInterface to verify successful
initialization of AudioPolicyManager.

A similar change is done in AudioFlinger constructor.
Also added some missing protections in AudioFlinger methods where the
playback thread list is parsed.

Change-Id: I006b244ec057e1bb0aa5ebe426ef006e3b171056
2011-01-19 09:04:27 -08:00
Eric Laurent
58bf1d9165 Fix issue 3317627.
The fix consists in selecting the digital audio device (SPDIF/HDMI)
when available if the routing strategy is STRATEGY_PHONE.

Change-Id: Ie500ae92f5c01f2511988543852ba559c6e5994b
2011-01-09 16:05:30 -08:00
Eric Laurent
e7155e6bde Fix issue 3217707.
The problem is that when the A2DP headset is disconnected, there is a transition
period during which the A2DP sink pumps data at a very high pace.
This makes that:
1 the audio flinger mixer thread spins and starves binder threads thus delaying
the completion of the A2DP output stream shutdown
2 we read the audio http audio stream faster than normal and we reach the end of stream
for audio while video is still playing if the streamed file is small enough.

The fix consists in detecting abnormal short write intervals and sleep to restore
a normal write pace.

Change-Id: Iab127882494ab0e26266371dc0ce5c2ff6fa476e
2010-12-17 10:27:02 -08:00
Eric Laurent
aef0cbb885 Fix speakerphone routing to analog dock
The audio routing policy when speakerphone is on and a dock with built-in
speakers is connected should be to output audio to teh dock speakers

Also removed route to SCO car kit if forced usage is not SCO as the SCO
socket might not be established.

Change-Id: I1aa2954092e28de935304b90f7a7a64d661934c7
2010-12-16 09:44:42 -08:00
Eric Laurent
2c61bee2b0 Change audio routing policy for HDMI
HDMI device should have a higher priority than analog dock audio but a lower priority
than wired headsets.
Also modified AudioService so that HDMI is mapped to DEVICE_OUT_AUX_DIGITAL device and not
DEVICE_OUT_DGTL_DOCK_HEADSET as before to enable discrimination between SPDIF going to
digital dock and SPIDF going to HDMI.

Change-Id: I887d0c73479784dd2edaf41ce1a7d8d0bdcbb4bd
2010-12-15 11:01:48 -08:00
Eric Laurent
4f9e0f173e Fix audio mode log.
Since the new audio mode IN_COMMUNICATION was added, the audio mode log
was broken.

Change-Id: I4fdafc3b98a1b0ceb55058a9e47fed99b3dbe6ad
2010-12-10 11:46:12 -08:00
Eric Laurent
e4eaa317f6 Fix issue 2641884: Bluetooth volume is dependent on in call volume.
The problem is that the code in AudioPolicyManagerBase::checkAndSetVolume() that forces
voice volume to max when setting bluetooth SCO volume is not called if the bluetooth stream
volume did not actually change. So even if we re apply volumes when switching to bluetooth
device, the volume voice volume is not changed and remains what it was when routed to earpiece
What makes things worse on Passion is that stream volumes are limited when connected to bluetooth
and their actual value does not change as soon as they exceed the limit threshold.

Change-Id: Id7c317db45b392a1c20dca2859678e3c64a371ed
2010-12-01 14:25:39 -08:00
Eric Laurent
fad778754c resolved conflicts for merge of 0d28be68 to master
Change-Id: Iec5f810c366d3e1c14a6f6294b0aea4ffb30ae3e
2010-12-01 12:11:10 -08:00
Eric Laurent
b87b53d7a8 Fix issue 3142808.
There is a bug in the way audio policy manager handles A2DP interface suspend/restore
when SCO is used. This bug is not new but has been triggered by a change in the timing
of the events received by audio policy manager when a call is setup and torn down
introduced by commit 164a8f86c7e48992691368c4895709c3bdb835a4.

The fix consists in grouping the control of A2DP suspended state in a single function
that is called systematically when conditions affecting this state are changed:
- call state change
- device connection/disconnection
- change in forced usage.

Change-Id: I46ee2399ee5547b60511fc6cfd32e2720091b0f8
2010-12-01 09:45:33 -08:00
Eric Laurent
6dc08b3667 Fix issue 3225810.
Take a wake lock whenever A2DP output stream is active.

Change-Id: Ie50e6d4cb34c8a1ba97b301ef25e10aeb153d8f3
2010-11-24 13:04:01 -08:00
Eric Laurent
f3d6dd0782 Fix issue 3157123.
Use a Mutex wherever atomic operations were used in AudioTrack,
AudioRecord, AudioFlinger and AudioEffect classes.

Change-Id: I6f55b2cabdcd93d64ef19446735b8f33720f8dbc
2010-11-19 15:49:42 -08:00
Jean-Michel Trivi
8f677d66d9 Add new audio mode for audio communications other than telelphony.
The audio mode MODE_IN_CALL signals the system the device a phone
 call is currently underway. There was no way for audio video
 chat or VoIP applications to signal a call is underway, but not
 using the telephony resources. This change introduces a new mode
 to address this. Changes in other parts of the system (java
 and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
 state variable directly, but to use two new convenience methods,
 isInCall() and isStateInCall(int) instead.

Change-Id: Id744cd26520ea1d1a4795eabe6a1f0c58789af76
2010-11-16 10:23:37 -08:00
Jean-Michel Trivi
1a22bdb01a Add support for audio recording source in generic audio policy mgr.
Update the platform-independent audio policy manager to pass the
 nature of the audio recording source to the audio policy client
 interface through the AudioPolicyClientInterface::setParameters()
 method.

Change-Id: I6b4fd0f8a3acea0d7d30bbad98edd1977dc012bf
2010-11-12 14:35:52 -08:00
Jean-Michel Trivi
820b9e0d3b Add recording source for voice communication
Add a recording source used to designate a recording stream for
voice communications such as VoIP.

Change-Id: I4091d67069b1a0170c1a5ca5e6acd51eb0aa08f9
2010-11-09 14:32:43 -08:00
Praveen Bharathi
21e941bf43 Added support for dock headset observer
Change-Id: I06b2e65e3bfa10735e6c7fd3349afa9ae7d45292
Signed-off-by: Praveen Bharathi <pbharathi@motorola.com>
2010-11-01 18:41:19 -07:00
Eric Laurent
786c57150c am ce2e2184: am 37947afe: Merge "Fixed AudioFlinger not always pausing tracks" into gingerbread
Merge commit 'ce2e2184bbc5530f4fac3220fdf3d1b3fc08a4c3'

* commit 'ce2e2184bbc5530f4fac3220fdf3d1b3fc08a4c3':
  Fixed AudioFlinger not always pausing tracks
2010-10-07 12:23:39 -07:00
Eric Laurent
9a30fc13f5 Fixed AudioFlinger not always pausing tracks
If the pause request is received before the AudioTrack buffer was
completelly filled and the track ready for mixing, the pause is
not executed: the track just underruns and stays in pausing state.

The fix consists in considering the track ready for mixing immediately
if pausing.

Change-Id: Ia6cb4703fee2126e41011a6400ea8eeb3a3e5456
2010-10-05 14:41:42 -07:00
Eric Laurent
785c416ecf am de12c3cf: am 220ab887: Merge "Issue 3032913: improve AudioTrack recovery time" into gingerbread
Merge commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9'

* commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9':
  Issue 3032913: improve AudioTrack recovery time
2010-09-30 19:47:21 -07:00
Eric Laurent
4712baab81 Issue 3032913: improve AudioTrack recovery time
This issue showed that when an AudioTrack underruns during a too long period
of time and is therefore disabled by audioflinger mixer, it takes an additional
delay of up to 3 seconds to recover.
This fix adds a simple mechanism to recover immediately when the client application
is ready to write data again in the AudioTrack buffer

Also throttle warnings on record overflows

Change-Id: I8b2c71578dd134b9e60a15ee4d91b70f3799cb3d
2010-09-30 17:21:23 -07:00
Eric Laurent
c9a9800fa1 am b047e3cd: am aeb2c62e: Merge "Fix several audio effects problems." into gingerbread
Merge commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c'

* commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c':
  Fix several audio effects problems.
2010-09-28 17:39:54 -07:00
Eric Laurent
4fd3ecc1f0 Fix several audio effects problems.
Fixed the following issues in LVM effect bundle wrapper:
- memory leaks in EffectCreate() in case effect creation fails at various stages
- Added saturation when accumulating to output buffer
- Fixed problems with enabled effects count when an effect is released while enabled
- Do not allocate temporary buffer for accumulation each time process() is called

Fixed the following issues in effects framework (AudioFlinger)
- Release effect synchronously in the library when deleted from effect chain
- Do not call the effect process function if no tracks are present in the same
audio session

Change-Id: Ifbd80a163415cfb3c0a337c12082853ea45d9c91
2010-09-28 14:23:39 -07:00
Eric Laurent
8fee382010 am 692dfafe: am 880dfe4f: Merge "Fix issue 3007862" into gingerbread
Merge commit '692dfafe02d04cdbab5367546e166580c92e4d2e'

* commit '692dfafe02d04cdbab5367546e166580c92e4d2e':
  Fix issue 3007862
2010-09-24 10:34:28 -07:00
Eric Laurent
98c92599ac Fix issue 3007862
Removed a cross deadlock condition between audioflinger and audio policy
service mutexes.
Audioflinger::createEffect() locks audioflinger mutex and then calls
AudioSystem::getOutputForEffect() which ends up in
AudioPolicyService::getOutputForEffect() which locks audio policy service
mutex. If at the same time, the command thread in audio policy service is
processing a command(set volume, set route...), the mutex is locked and the
command will call one audioflinger method which in turn will attempt to
lock audioflinger mutex.
The fix consists in releasing audioflinger mutex before calling
getOutputForEffect().

Change-Id: Id44e7feb36e0a295731f6aa97cf32d022edd34d0
2010-09-24 09:32:40 -07:00
Eric Laurent
ec0efd0ceb am 11746caa: am 08959c63: Merge "Request permission for global audio effects." into gingerbread
Merge commit '11746caaa852984ff186bf5b8807e2c14cd7c1bc'

* commit '11746caaa852984ff186bf5b8807e2c14cd7c1bc':
  Request permission for global audio effects.
2010-09-22 17:04:48 -07:00
Eric Laurent
14beea487c Request permission for global audio effects.
Applications creating an audio effect on the output mix must
have the MODIFY_AUDIO_SETTINGS permission.

Change-Id: I57d88533f91ad0d33680107d79abcec28f7263b5
2010-09-22 15:58:38 -07:00
Eric Laurent
e931c68f53 am 4d987850: am bd2e9ec6: Merge "Fix volume problems with insert revert" into gingerbread
Merge commit '4d9878502f7661ed34540a485a5942d859e209c7'

* commit '4d9878502f7661ed34540a485a5942d859e209c7':
  Fix volume problems with insert revert
2010-09-13 14:42:59 -07:00
Eric Laurent
27a2fdfb8a Fix volume problems with insert revert
- Use a constant input level to the reverb engine and implement volume control in the
insert reverb. This avoids the volume spikes when an effect that was inserted after
the reverb is disabled or removed.
- Fix clicks (one silent buffer) at the end of the reverb disable period.
- Modified volume management in audioflinger so that the volume ramp is also done by
the insert effect if present when the track is paused (avoids clicks).
- Increased room level for all presets.

Also fixed problems with output stage session (-1):
- effect bundle wrapper was not designed to support session -1
- the permission check in audioflinger for using session -1 failed due to a wrong usage of
getCallingPid()

Change-Id: Id1ff51327263364bf71d3f2668fa5cde4311d84f
2010-09-13 09:08:28 -07:00