summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Improve resistance to leaks for ConfigEvent"Glenn Kasten2011-12-151-1/+1
|\
| * Improve resistance to leaks for ConfigEventGlenn Kasten2011-12-151-1/+1
| | | | | | | | | | | | | | | | A Vector of pointers is risky, as there is no ownership (and the ThreadBase destructor was not deleting them, so if there were any left over at end it would leak). Replaced by a Vector of values. Change-Id: Iddde72dc30134adfcf724dec26cbe0a742509b8c
* | Use NULL not 0 for pointersGlenn Kasten2011-12-151-2/+2
|/ | | | Change-Id: Iab3f9abbdab617dc5a599e657ec46a0b0a002eef
* audioflinger: fix audio skipping over A2DPEric Laurent2011-12-051-2/+1
| | | | | | | | | | | | | | The maximum sleep time allowed in the mixer thread when audio tracks are enabled but not ready for mixing is derived from the latency reported by the output stream. This does not work for A2DP where the latency also reflects encoding, decoding and transfer time. Modified activeSleepTimeUs() to take A2DP case into account. Issue 5682206. Change-Id: I3784ac01fb6f836b5a6ce6f764fb15347586de35
* audioflinger: fix noise when skipping to next songEric Laurent2011-11-111-1/+8
| | | | | | | | | | | | | | | | | When audio effects are enabled, a noise can be heard at the beginning of the new song when skipping to next song in music app. This is because some effects (especially virtualizer) have a tail. This tail was not played when previous song was stopped because effects were not processed when no tracks were present on a given session. This is to reduce CPU load when effects are enabled but no audio is playing. The tail was then rendered when the new song was started. Added a delay before stopping effect process after all tracks have been removed from a session. Issue 5584880. Change-Id: I815e0f7441f9302e8dfe413dc269a94e4cc6fd95
* Fix issue 381905: BassBoostTest CTS tests fail...Eric Laurent2011-10-191-3/+5
| | | | | | | | | | | | | | | | | | | When AudioEffectTest is executed, an Equalizer is created and enabled on a MediaPlayer session. Effects on the output mix are therefore suspended. Then the MediaPlayer is released with the effect still enabled. In this case, Audioflinger::purgeStaleEffects_l() fails to restore the suspended effects when the effect attached to the released audio session is removed. When subsequent tests are executed on output mix effects, these effects cannot be enabled as they are still suspended. Fixed purgeStaleEffects_l() to restore suspended effects if the effect removed is enabled. Also fixed EffectHandle::disconnect() to only restore suspended effects if the disconnected handle actually has control over the effect. Change-Id: I67232e7c34680b0cc01abfd57d5d510a524e5d4f
* Fix issue 5381089: problem with A2DP music volumeEric Laurent2011-10-051-0/+1
| | | | | | | | | | | | This problem only occurs when audio effects are present and the music volume is applied by one effect engine. When connecting or disconnecting A2DP, audio effects are moved from one mixer thread to another. When removed from the source thread, the effect is stopped but it is not restarted when added to the destination thread. This regression was introduced by commit 21b5c47e. Change-Id: I4cc578d8d760ec65b185032b6fda98c739d331bc
* Merge "226483: A2DP connected, but music out to speaker"Eric Laurent2011-08-301-1/+5
|\
| * 226483: A2DP connected, but music out to speakerEric Laurent2011-08-301-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the A2DP headset is connected, there is a possible race condition when the audio tracks are moved from the mixer thread attached to the speaker output to the thread attached to A2DP output. As the request to clear the stream type to output mapping cache in the client process is asynchronous, it is possible that the flag indicating to the client audio track to re-create the IAudioTrack on the new thread is processed before the cache is invalidated. In this case, the track will be attached to the old thread and music will continue playing over the device speaker instead of being redirected to A2DP headset. Change-Id: Ib2ce1eb5320eaff83287b93779061bf4e7a330df
* | Audioflinger: reverse logic of BT NREC indicationEric Laurent2011-08-291-2/+2
|/ | | | | | | | The interpretation of BT NREC by AudioFlinger to enable or disable AEC and NS was wrong: NREC to ON (default) means the phone (Audio Gateway) must enable local AEC and NS. Change-Id: I88a264e7fc9831c43bbace4f6b585baec73f2006
* Audio effects: track CPU and memory use separatelyEric Laurent2011-08-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | Before this change, CPU and memory usage for an audio effect were registered and checked against the limit by audio policy manager upon effect instantiation. Even if an effect was not enabled it would prevent another effect to be created if the CPU load budget was exceeded, which was too restrictive. This change adds a method to register/unregister CPU load only when an effect is enabled or disabled. It also adds a mechanism to place all effects on the global output mix in suspend state (disabled) when an effect is enabled on a specific session. This will allow applications using session effects to have the priority over others using global effects. Also fixes some issues with suspend/restore mechanism: - avoid taking actions when an effect is disconnected and was not enabled. - do not remove a session from the suspended sessions list when corresponding effect chain is destroyed. Change-Id: I5225278aba1ae13d0d0997bfe26a0c9fb46b17d3
* Keep effects sessions active when the caller dies.Marco Nelissen2011-08-091-5/+26
| | | | | | | | Don't remove effects until the session they are in goes away or all AudioEffects have been explicitly released. This allows the control panel process to die without stopping the effects. Change-Id: I4496e5df080230ca1af149dec95c1309ab8ea888
* Merge "AudioFlinger: protect input/output stream access"Eric Laurent2011-08-081-5/+7
|\
| * AudioFlinger: protect input/output stream accessEric Laurent2011-08-081-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some methods would not check that the output orinput stream of a thread was still valid before calling functions on its interface. This could cause a crash if those methods where called while the output or input was being closed by another thread. Make sure that the output or input stream pointer is cleared before closing the stream. Always check that the output or input pointer is not null before calling functions at the stream interface. Generalize the use of initCheck() method to verify that the output or input stream is not null. Change-Id: I9d9ca6b744d011bcf3a7bbacb4a581ac1477bfa5
* | AudioFlinger: disable AEC and NS with BT headsetsEric Laurent2011-08-031-1/+5
| | | | | | | | | | | | | | Disable AEC and NS when the Bluetooth SCO headset in use indicates it implements those pre processings. Change-Id: I93f3d10b0a27243d5dbff7182639576fc0c6d862
* | Audio Effect Framework: add effect suspend/restoreEric Laurent2011-08-021-5/+83
|/ | | | | | | | | | Add the possibility for the effect framework to suspend (temporarily disable process) and restore audio effects. This feature will be usefull to disable pre processing under certain conditions and better control coexistence of audio effects on output mix and specific sources. Change-Id: I79b195982cc48748d5708308fb1647b9c3c34cc6
* Merge "AudioFlinger: fix crash when deleting pre process."Eric Laurent2011-07-271-1/+3
|\
| * AudioFlinger: fix crash when deleting pre process.Eric Laurent2011-07-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a pre processing effect is detroyed while enabled and capture is active, there was a possibility that the effect engine is released by the framework while still processed by the audio HAL. The fix consists in not releasing the engine in EffectModule::removeHandle() but just flag the effect as being detroyed to avoid further calls to functions on the engine effect interface. The effect interface is then removed from the audio HAL safely in EffectChain::removeEffect_l() while holding the EffectChain mutex. Change-Id: I71fab30d9145062af8644f545a1f1d4d3e7e7f02
* | Fix issue 4604090: notification sound interrupted.Eric Laurent2011-07-251-0/+29
|/ | | | | | | | | | | | | The problem is that the audio HAL fails to acquire the wake lock when playing the notification. This is because of a change that removed the mediaserver process form the system group for honeycomb. The fix consists in requesting the wake lock from PowerManagerService when AudioFlinger mixer wakes up. A consequence of this change is that audio HALs or pcm drivers do not have to hold wake locks anymore as in the past. Change-Id: I4fb3cc84816c9c408ab7fec75886baf801e1ecb5
* AudioFlinger: add dump of audio pre processing.Eric Laurent2011-07-241-1/+1
| | | | | | | | Dump of media.audio_flinger service was only listing effects on output threads. Moved the dump of effect chains from PlaybackThread to ThreadBase class so that pre processings on RecordThread are also listed. Change-Id: If8bc74023c12b9c2371f1b300743b156ceca7b87
* Audio framework: support for audio pre processingEric Laurent2011-07-181-53/+104
| | | | | | | | | | | | | | | | | | | | | | | | | Audio effect framework is extended to suport effects on output and input audio path. AudioFlinger: Support for audio effects and effect chains is moved from PlaybackThread class to ThreadBase class so that RecordThread can manage effects. Effects of type pre processing are allowed on record thread only. When a pre processing is enabled, the effect interface handle is passed down to the input stream so that the audio HAL can call the process function. The record thread loop calls the effect chain process function that will only manage the effect state and commands and skip the process function. AudioRecord: The audio session is allocated before calling getInput() into audio policy serice so that the session is known before the input theead is created and pre processings can be created on the correct session. AudioPolicyService: default pre processing for a given input source are loaded from audio_effects.conf file. When an input is created, corresponding effects are created and enabled. Change-Id: Id17119e0979b4dcf189b5c7957fec30dc3478790
* audio: update for audio/audio_policy header names/locationsDima Zavin2011-06-131-1/+1
| | | | | Change-Id: I36c49352eee57559403cd1597f56a8485a360289 Signed-off-by: Dima Zavin <dima@android.com>
* Use channel mask instead of channel count for track creationJean-Michel Trivi2011-06-011-20/+24
| | | | | | | | | | | | | | | | | Record and playback objects (resp AudioRecord and AudioTrack) are created using a channel mask, but this information is lost in the mixer because only the channel count is known to AudioFlinger. A channel count can always be derived from a channel mask. The change consists in: - disambiguiting variable names for channel masks and counts - passing the mask information from the client to AudioFlinger and the mixer. - when using the DIRECT ouput, only verifying the format of the track is compatible with the output's for PCM. Change-Id: I50d87bfb7d7afcabdf5f12d4ab75ef3a54132c0e
* Removed interface to load audio effects librariesEric Laurent2011-05-271-4/+0
| | | | | | | Removed unused functions allowing dynamic loading of audio effects libraries from effects factory API. Change-Id: I06cc5a51dc10aca87c7a8687bbb874babd711eca
* New effect library APIEric Laurent2011-05-271-9/+1
| | | | | | | | | | | | | | | | | Moved and renamed media/EffectApi.h to hardware/audio_effect.h Modified the effect library API to expose a library info structure containing an interface functions table. Also removed enums for audio channels, audio format and devices from effect API and use values from system/audio.h instead. Modified effects factory to support new library interface format and load libraries and efffects listed in audio_effects.conf file. The file audio_effects.conf is first loaded from /vendor/etc and then from /system/etc/audio_effects.conf if not found. Modified existing effect libraries to implement the new library interface. Change-Id: Ie52351e071b6d352fa2fbc06c3846686f8c45df9
* Merge "Fix audio effect framework issues"Eric Laurent2011-05-131-4/+10
|\
| * Fix audio effect framework issuesEric Laurent2011-05-131-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix two issues in audio effect framework reported by partners. 1 - Fixed duplicated audio buffer sent to effect process function when pausing a track. Modified Effectchain::process_l() function to clear the effect chain input buffer before calling the effect process functions when no track is active on the session. Previous code was clearing the buffer after calling the process functions and when transitioning from active to inactive, the last processed buffer was passed again once to effect process function before being cleared. 2 - Fixed potential mutex cross deadlock when disconnecting an effect while playback is active. This is because EffectChain::process_l() was calling PlaybackThread::hasAudioSession() thus creating an inversion in the mutex lock order (EffectChain mutex locked before ThreadBase mutex). The fix consists in removing the call to hasAudioSession() from process_l() and requires each effect chain to keep count of the number of audio tracks attached to it (previously only the active tracks were accounted for). Change-Id: Iee4246694ea8c7a66c012120c629d72dd38f9c35
* | update for new audio.h header locationDima Zavin2011-05-121-1/+1
|/ | | | | Change-Id: Ic4c62c4037800802427eb7d3c7f5eb8b25d18876 Signed-off-by: Dima Zavin <dima@android.com>
* audioflinger: don't do work in constructor, instead do it in onFirstRefDima Zavin2011-04-271-0/+2
| | | | | Change-Id: I22d9e01821816c3beb52b014330386c7fd2f0411 Signed-off-by: Dima Zavin <dima@android.com>
* audioflinger: enumerate all the possible audio interfacesDima Zavin2011-04-271-12/+32
| | | | | | | | Keep track of the primary interface that handles the master volume, etc. Change-Id: Ib0701fccff8d8783a99035a241ab7c8ec75c00ac Signed-off-by: Dima Zavin <dima@android.com>
* audio/media: convert to using the audio HAL and new audio defsDima Zavin2011-04-271-13/+14
| | | | | Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5 Signed-off-by: Dima Zavin <dima@android.com>
* Merge "Bug 3366885 Remove LVMX switch"Glenn Kasten2011-02-031-3/+0
|\
| * Bug 3366885 Remove LVMX switchGlenn Kasten2011-02-031-3/+0
| | | | | | | | Change-Id: I0bf98c6f85f00b3296874571e1c049dcc4e2fcca
* | Fix issue 3371080Eric Laurent2011-02-031-4/+0
|/ | | | | | | | | | | | | | | | | | | | | | 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
* Fix issue 3157123.Eric Laurent2010-11-191-1/+1
| | | | | | | Use a Mutex wherever atomic operations were used in AudioTrack, AudioRecord, AudioFlinger and AudioEffect classes. Change-Id: I6f55b2cabdcd93d64ef19446735b8f33720f8dbc
* Audio Effects: fix problems in volume control.Eric Laurent2010-08-311-0/+2
| | | | | | | | | | | | | - Fixed click when re-enabling effect during the turn off phase: make sure the effect states where effect is processed are the same where volume control is delegated to effect. - Fixed click when effect is deleted while still active: do not apply volume ramp if an effect having volume control was just removed from the effect chain. Also fixed a crash when PCM dump is enabled in effect bundle wrapper. Change-Id: Ib562f5cf75c69af75df0e862536262e2514493e4
* Fix issue 2929440Eric Laurent2010-08-191-0/+3
| | | | | | | | Fixed regression introduced by change a54d7d3d7dd691334189aab20d23c65710092869 in audioflinger mixer thread: When the output stream is suspended, the sleep time between two writes must match the actual duration of one output stream buffer otherwise the playback rate is not respected. Change-Id: Ic5bebe890290d1f44aeff9dd3c142d18e26fff2a
* Allow creation of an audio effect on a session with no audio tracks.Eric Laurent2010-07-291-2/+11
| | | | | | | | This is necessary to allow creating and enabling an effect attached to a particular player session before the playback is started. As a matter of fact, the implementation of the mediaplayer does not create the AudioTrack before playback starts. Change-Id: I1266e8885f9d756acc949303321aaac0fbf83e34
* Audio effects: modified command() parameter types.Eric Laurent2010-07-281-3/+15
| | | | | | | The type of the cmd, cmdSize and *pReplySize parameters of the effect control interface command() function have been modified from int to uint32_t. This is more consistent with their role. Change-Id: I84d289fc262d6753747910f06f485597dfee6591
* Audio policy manager changes for audio effectsEric Laurent2010-07-201-17/+33
| | | | | | | | | | | | | | | Added methods for audio effects management by audio policy manager. - control of total CPU load and memory used by effect engines - selection of output stream for global effects - added audio session id in parameter list for startOutput() and stopOutput(). this is not used in default audio policy manager implementation. Modifications of audio effect framework in AudioFlinger to allow moving and reconfiguring effect engines from one output mixer thread to another when audio tracks in the same session are moved or when requested by audio policy manager. Also fixed mutex deadlock problem with effect chains locks. Change-Id: Ida43484b06e9b890d6b9e53c13958d042720ebdb
* Fixed problems in audio effect volume control.Eric Laurent2010-07-191-0/+3
| | | | | | | | | | Fixed the following problems in audio effect volume control in AudioFlinger: - Make sure that the volumes returned by EffectChain::setVolume_l() are correct even is no change is detected since last call - Do not use isEnabled() to validate volume control but mState >= ACTIVE instead as the volume control must be also active in STOPPING and STOPPED states. Change-Id: Id62da3164fad500ee8a5efd6cd78c77e8fdcb541
* Several improvements in audio effects volume control.Eric Laurent2010-07-151-9/+10
| | | | | | | | | | - Fixed crash when deleting an effect chained before an effect having volume control - Changed EFFECT_FLAG_VOLUME_CTRL to implicitely include EFFECT_FLAG_VOLUME_IND (not need to set both in effect descriptor). - Volume control changes from one effect to another if needed according to effect enable state - EFFECT_CMD_SET_VOLUME is only sent when their is an actual change in volume Change-Id: Ieebaf09157e2627366023569d95516646e03e26c
* added BinderService<> template to help creating native binder servicesMathias Agopian2010-07-141-3/+8
| | | | Change-Id: Id980899d2647b56479f8a27c89eaa949f9209dfe
* move native services under services/Mathias Agopian2010-07-141-0/+1148
moved surfaceflinger, audioflinger, cameraservice all native services should now reside in this location. Change-Id: Iee42b83dd2a94c3bf5107ab0895fe2dfcd5337a8