summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DO NOT MERGE - improve audio effect framwework thread safetyEric Laurent2017-03-221-18/+33
| | | | | | | | | | | | | | | | | | | | | | - Reorganize handle effect creation code to make sure the effect engine is created with both thread and effect chain mutex held. - Reorganize handle disconnect code to make sure the effect engine is released with both thread and effect chain mutex held. - Protect IEffect interface methods in EffectHande with a Mutex. - Only pin effect if the session was acquired first. - Do not use strong pointer to EffectModule in EffectHandles: only the EffectChain has a single strong reference to the EffectModule. Bug: 32707507 CVE-2017-0479 CVE-2017-0480 CVE-2017-0499 Change-Id: Ia1098cba2cd32cc2d1c9dfdff4adc2388dfed80e (cherry picked from commit b378b73dd7480b584340b8028802c9ca2d625123) (cherry picked from commit 22e26d8ee73488c58ba3e7928e5da155151abfd0 with backport by <sultanxda@gmail.com>)
* audioflinger: Always process volume commands from a latest trackHaynes Mathew George2016-08-191-9/+3
| | | | | | | | | Process them irrespective of whether the track is invalid. Ignoring to do so may lead to glitches/loud bursts in audio when a new track reuses the same output. CRs-Fixed: 1002448 Change-Id: I9afbdd221db3a7311eb0ec8bb75852cf5409084e
* audioflinger: set flush pending on invalidating offload trackHaynes Mathew George2016-08-191-2/+14
| | | | | | | | | | | | | | | | | | On invalidating an offload track, the IAudioTrack instance is destroyed and the offload output is released. If it so happens that APM::getOutputForAttr for the new IAudioTrack is called before OffloadThread::prepareTracks_l checks and removes an invalid track, the same output can get reused. The side effect of this is data present in HAL and below from before the invalidate will be rendered before data from the new seek position is rendered. This is unexpected. To fix this, set hint to issue flush when an offload track is invalidated. Bug: 28566885 CRs-Fixed: 1002438 Change-Id: Ib6c38a3abb600598b87591bac90d03b7150d5216
* Don't place large objects on the stackGlenn Kasten2016-08-191-5/+13
| | | | | Bug: 25020816 Change-Id: Ife4da9fc3000e645f654f2eb28b37ad3a89d61f9
* audio: use offload standby delay for direct pcmWeiyin Jiang2016-04-031-0/+2
| | | | | | | | | Default standby delay for legacy direct is too aggressive for track offloaded use case. Using offload standby delay instead, which allows sufficient time for track transition before standby the output. CRs-Fixed: 982822 Change-Id: Ifd0e39c5b3fe4a4af9f444dbbad21ef1e1a5edfa
* audio: allow standby for direct trackWeiyin Jiang2016-04-031-0/+4
| | | | | | | | | | | Delay standby for offload track use case is not suitable for direct track in PCM format, because player torn down doesn't necessarily happen. To avoid AP looping infinitely, allow standby right after direct track in PCM format is paused. CRs-Fixed: 986784 Change-Id: Id0026ac9891a12acc4affa446b2bc841559fcc28
* Merge tag 'android-6.0.1_r22' of ↵Steve Kondik2016-03-101-3/+20
|\ | | | | | | | | | | https://android.googlesource.com/platform/frameworks/av into cm-13.0 Android 6.0.1 release 22
| * audioflinger: fix standby delay on A2DP outputEric Laurent2016-01-121-3/+20
| | | | | | | | | | | | | | | | | | | | | | Make sure that standby delay is never less than the audio flinger default on A2DP output. Due to variable latency and amount of buffering in A2DP sinks, an agressive standby delay could lead to truncated audio. Bug: 25830539. Change-Id: I38be37ad346f5f4bf8303d3db4e3e911bf637968 (cherry picked from commit 42537be61479e59c4718e1304364551c1454f63c)
* | Combine 'DTS Sound (TruMedia) Postpro support in frameworks/av for Android ↵jinamdar2016-02-011-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | 6.0' as a single patch. Signed-off-by: jinamdar <jaydeep.inamdar@dts.com> (cherry picked from commit d3668da66643d4cc39058fb65c8db0742748f70f) Conflicts: services/audioflinger/AudioFlinger.cpp services/audioflinger/Threads.cpp Change-Id: I67e3ba100ff40058919ba827b806aea7bdbaf4bb
* | audioflinger: update multiplier logic to calculate frameCountSatya Krishna Pindiproli2015-12-191-13/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the value of the multiplier used in calculating mNormalFrameCount is odd, it is rounded off to a higher even value. This results in an increase of mNormalFrameCount and thereby the latency which is not expected. Do not prefer an even multiplier and let the value remain as is even if it is odd. CRs-Fixed: 931454 Change-Id: Ia60d87d01caef6f45998bffeafc3d6a24f7c7fb4
* | libaudioflinger: avoid s/w effect processing in case of Direct PCMvivek mehta2015-12-191-2/+3
| | | | | | | | | | | | | | - Check Direct PCM usecase with Offload - do not process s/w effect when direct PCM is enabled Change-Id: I2eb843b17558e60cf36daff0c5fbdf50dccf99ca
* | audioflinger: Don't do float conversion in upmix/downmix for legacy ALSAArne Coucheron2015-12-071-0/+59
| | | | | | | | | | | | | | | | | | Legacy ALSA really hates floating point, and it's breaking mic input when doing things like audio recording. Use the old conversion routine for legacy ALSA. Change-Id: I616f4cd42fa0e4d7595dd61ed2d36c4fa7052c53
* | Merge tag 'android-6.0.1_r3' of ↵Steve Kondik2015-12-071-1/+4
|\ \ | |/ | | | | | | | | | | | | https://android.googlesource.com/platform/frameworks/av into cm-13.0 Android 6.0.1 release 3 Change-Id: I2f2a1fe1b58c828e8341556996211562d6e195ab
| * am 4c6e77ff: AudioFlinger: Clear record buffers when starting RecordThreadAndy Hung2015-10-131-1/+4
| |\ | | | | | | | | | | | | * commit '4c6e77ff8e18a1551320a6b42f6a45e19dcce748': AudioFlinger: Clear record buffers when starting RecordThread
| | * AudioFlinger: Clear record buffers when starting RecordThreadAndy Hung2015-10-131-1/+4
| | | | | | | | | | | | | | | | | | Bug: 24211743 Bug: 24267152 Change-Id: I58c55e56b85067b71e4e300f947b4dfc159637ba
* | | audioflinger: Fix effect can't be added for mono channel input.Manish Kumar2015-12-071-1/+1
| | | | | | | | | | | | | | | | | | Don't forbid effects being added for mono channel. Change-Id: Ib080c6c9ac263239668b639a788c29154726210d
* | | audioflinger: Adjust throttle interval when effects in useSteve Kondik2015-11-271-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Loud clicks/pops are heard when playing to a USB device with AudioFX enabled. Particularly frequent when the USB device is capable of high-resolution output. * Adjust the throttling period when effects are enabled to prevent this. Change-Id: I3db220d13c37f4ff5b835c14831fbe6f5a5b062c
* | | audio: Set OutputFormat of AudioMixer to PCM16Ramjee Singh2015-11-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | - MixerThread sets OutputFormat to PCM_FLOAT by default We are having issue with SRS Effects due to this format - Fix is to select always PCM16 format as Audio HAL supports only PCM16 Change-Id: I26d23836180fe95b4c32b071593827b6fe4d674e
* | | Merge tag 'android-6.0.0_r26' into cm-13.0Ricardo Cerqueira2015-11-051-1/+7
|\ \ \ | |/ / | | | | | | | | | | | | Android 6.0.0 release 26 Change-Id: I8a57007bf6efcd8b95c3cebf5e0444345bdd4cda
| * | CameraService: Use SCHED_FIFO for request queue thread in HFREino-Ville Talvala2015-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Move SchedulingPolicyService from audioservice to mediautils - When starting up a high speed stream config, set request queue thread to SCHED_FIFO using SchedulingPolicyService Bug: 24227252 Change-Id: I224b59142bd111caf563779f55cddd62385b9bac
| * | audio flinger: force audio path start from normal mixerEric Laurent2015-09-101-0/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The audio HAL wakes up and configures the audio path when receiving the first write() in standby state. This causes a certain amount of process to take place in the mixer threads which is problematic for fast mixer running at FIFO priority. We now force a fake write() of 0 bytes from normal mixer to trigger the audio path configuration before starting the fast mixer. Bug: 23791972. Change-Id: I54311b337fda956444846f5d2f53a3263d54e04b
* | Direct_PCM: add support for effectsvivek mehta2015-10-061-2/+14
| | | | | | | | | | | | - add support for effects on direct pcm output Change-Id: I2fbac63c623bf51a03e5e91828369739d33329f3
* | audio: add support to enable Direct PCM outputvivek mehta2015-10-061-1/+8
| | | | | | | | | | | | allow effects in case outout is direct pcm Change-Id: I2ad7eacf11642a4ca9f892b61124293d0dc503a9
* | audioflinger: clear effect buffers for duplicating outputYamit Mehta2015-10-061-1/+7
|/ | | | | | | | | | | -Clear effect buffers in threadloop_mix() in case audio effects enabled when output threads are not ready -Also clear mix buffers in threadLoop_sleepTime()when tracks are not ready CRs-Fixed: 765749 Change-Id: I475d42ac0cc68e4856002a9bd4c6c256a6fca70c
* Merge "Fix capture overruns at non-primary sample rate" into mnc-devGlenn Kasten2015-07-241-14/+6
|\
| * Fix capture overruns at non-primary sample rateGlenn Kasten2015-07-221-14/+6
| | | | | | | | | | | | | | | | | | and small buffer size. Also: Pull out the magic number "12 ms" to a named constant. Remove obsolete AudioFlinger::mPrimaryOutputSampleRate. Bug: 22662814 Change-Id: I261f75a222c4505a84aad2493d251bd2dea59f68
* | Fix record memory buffer allocation for legacy upmix/downmixAndy Hung2015-07-221-1/+1
|/ | | | | Bug: 22173057 Change-Id: I8f5056ff5a1252c71a3d3b354440551bcd9fd466
* AudioFlinger: fix repeated underruns for compressed audioPhil Burk2015-07-171-4/+12
| | | | | | | | | | | | | | | | | | | | | | The AudioFlinger kept pausing the audio when playing compressed AC3 or DTS. This caused pause/resume loops that were hard to break out of. The AudioFlinger was thinking that the compressed audio was PCM because the HAL was in PCM mode playing SPDIF data bursts. It also thought that EAC3 was at 192000 Hz instead of 48000 Hz because the data bursts are played at a higher rate. This CL adds more calls to the shim that separates the AudioFlinger. Now the AudioFlinger gets information about the HAL sample rate, channel masks and format from the shim instead of calling the HAL directly. The AudioFlinger now uses a different threshold for detecting underruns when the audio is compressed. Bug: 19938315 Bug: 20891646 Change-Id: Ib16f539346d1c7a273ea4feb3d3afcc3dc60237d Signed-off-by: Phil Burk <philburk@google.com>
* Merge "audioflinger: flush HAL when transitioning to next direct track" into ↵Eric Laurent2015-07-131-9/+12
|\ | | | | | | mnc-dev
| * audioflinger: flush HAL when transitioning to next direct trackEric Laurent2015-07-071-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Send flush command to the audio HAL when transtioning to next track on direct output thread, even if both tracks are in the same audio session. Commit 43b4dcc to fix issue 21145353 did only flush the HAL if the audio session was different for the new track because the logic was copied from the offload thread. Bug: 22019044. Change-Id: I89b217580023ed7449a58e9bf3dc068ce7a84487
* | audio: several fixes in audio routing callbacksEric Laurent2015-07-101-11/+16
|/ | | | | | | | | | | | | | | | | | | | | | - audio policy: Force device change to ensure new audio patch creation upon first track activity on a given output. Fix function device_distinguishes_on_address() which could mistake some output device with remote submix input device. - audio flinger: Reduce number of binder calls upon new client registration by only sending ioConfigChanged() callbacks to newly registered client. Fix first patch after output thread creation not triggering an ioConfigChanged() callback. -audio system: Force client registration upon routing callback installation to force new ioConfigChanged() callback from audio flinger. Bug: 22381136. Change-Id: Ieb0d9f92f563a40552eb31bc0499c8ac65f78ce4
* audio: add definitions for devices connected over IPEric Laurent2015-07-061-0/+2
| | | | | Bug: 22068684. Change-Id: Idde0eaf7121d2e43f32eee3e6b10e99d8cff4912
* reduce number of binder calls from mediaserverEric Laurent2015-06-261-3/+12
| | | | | | | | | | | | | | | Reduce the number of audio port, audio patch and IO config changed binder calls from mediaserver to client processes: - Do not call IO config changed callback if selected device is the same as previously selected one on a given audio flinger playback or capture thread. - Do not call the audio port or audo patch list update callback on a client if this client as no listener registered. Bug: 22045560. Change-Id: If780e105404de79b7cb5c80c27b793ceb6b1c423
* Reduce log messages on AudioFlinger throttleAndy Hung2015-06-181-2/+15
| | | | | Bug: 21858740 Change-Id: I8f291b64c1033867bb57ffceaa3b7d94aa998715
* Merge "AudioFlinger: flush stream when switching tracks" into mnc-devPhil Burk2015-06-111-22/+40
|\
| * AudioFlinger: flush stream when switching tracksPhil Burk2015-06-111-22/+40
| | | | | | | | | | | | | | | | | | For direct threads, when recycling a stream, perform a flush so that the frame position is reset. Bug: 21145353 Change-Id: I08611cd64bb249a9659c44f9e4c47e7455f4838f Signed-off-by: Phil Burk <philburk@google.com>
* | Take advantage of audio_channel_in_mask_from_countGlenn Kasten2015-06-091-5/+3
|/ | | | | | Bug: 21375533 Bug: 21721483 Change-Id: I1ccd5d1d68a25f415dc4a62bf7a44d9db12a256b
* Throttle MixerThread data pull to no more than twice expected rateAndy Hung2015-06-031-3/+35
| | | | | | | | | | | | This helps prevent underruns with NuPlayer and other applications which set up buffers that are close to minimum size or use deep buffers, and rely on a double-buffering sleep strategy to fill. Enabled by default. Disabled by setting af.thread.throttle 0 Bug: 19062223 Bug: 21198655 Change-Id: Ia52b48e0c99588af5db53c43fede2afd775b8899
* Merge "Add more device codes for symbolic display" into mnc-devGlenn Kasten2015-05-291-0/+34
|\
| * Add more device codes for symbolic displayGlenn Kasten2015-05-271-0/+34
| | | | | | | | Change-Id: I08553f0e94d0a0931ccf98ee04f53686b96c8b03
* | audio flinger: add suffix to time variables namesEric Laurent2015-05-271-51/+51
| | | | | | | | | | | | | | | | | | | | | | Add suffix to clarify units for the following variables: standbyTime -> mStandbyTimeNs standbyDelay -> mStandbyDelayNs activeSleepTime -> mActiveSleepTimeUs idleSleepTime -> mIdleSleepTimeUs sleepTime -> mSleepTimeUs Change-Id: I7f5d602c39e0ef3f6fe9ef99eaf1b351c7bd4fc3
* | Merge "audio flinger: pause direct output when underrunning" into mnc-devEric Laurent2015-05-271-7/+7
|\ \ | |/ |/|
| * audio flinger: pause direct output when underrunningEric Laurent2015-05-261-7/+7
| | | | | | | | | | | | | | | | | | | | | | If a direct output supports pause, pause the stream instead of placing it into standby when the audio track underruns. This will avoid resetting the presented frame count and preserve A/V sync. Bug: 21437855. Change-Id: I598346edb62a1864126acdb1d9a937c82eac2191
* | Merge "audio flinger: do not call JAVA services until system is ready" into ↵Eric Laurent2015-05-211-35/+48
|\ \ | | | | | | | | | mnc-dev
| * | audio flinger: do not call JAVA services until system is readyEric Laurent2015-05-201-35/+48
| |/ | | | | | | | | | | | | | | Wait for system ready indication form AudioService before enabling calls to scheduling service or power manager. Bug: 11520969. Change-Id: I221927394f4a08fd86c9d457e55dd0e07949f0cf
* | Merge "Update FastTrack channel conversion check" into mnc-devAndy Hung2015-05-191-3/+5
|\ \
| * | Update FastTrack channel conversion checkAndy Hung2015-05-191-3/+5
| |/ | | | | | | Change-Id: Ia1a3124e6408859bf4d95ff9fd95dda6970a4a7f
* | Fix channel mask dump in AudioFlingerAndy Hung2015-05-191-43/+56
|/ | | | Change-Id: Iba5ccd1885775b14c44342c7b169a0672b93549b
* Merge "Update sampling rate to 192kHz for devices" into mnc-devAndy Hung2015-05-121-2/+5
|\
| * Update sampling rate to 192kHz for devicesAndy Hung2015-05-121-2/+5
| | | | | | | | Change-Id: I0a83206be51d7ae18ccf85b94b2127356307be69