summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make Audio wakelock names less unique.Narayan Kamath2013-10-141-2/+21
| | | | | | | | | | | | | | | These wakelocks now show up in the client process, where they might cause wakelock overflows if AudioFlinger threads die often. The client process should be agnostic of audio flinger threading, so don't make the wakelock names rely on audioflinger thread names. Wakelock names now depend only on the audio flinger thread type, and not the ID itself. bug: 11200551 Change-Id: Ia1f71b569cb7502d617b77596abc245f461a6ec0
* Merge "Cleanup openRecord error handling" into klp-devGlenn Kasten2013-10-071-1/+3
|\
| * Cleanup openRecord error handlingGlenn Kasten2013-09-241-1/+3
| | | | | | | | | | Bug: 10888816 Change-Id: I84897dd7d30b370640b54e928f230604b873cb68
* | audioflinger: offload: fix pause/flush/resumeEric Laurent2013-10-041-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a pause/flush/resume sequence is fast enough, resume is received while we are still in PAUSING state in which case it is a NOP. If this happens, flush is still forwarded to the audio HAL but is not preceeded by a pause which can cause problems to the audio DSP. It is necessary to preserve the flush as this sequence is typical to a seek. The fix consists in forcing a pause/resume when a flush request must be executed and the audio HAL has not been paused previously. Bug: 11081559. Change-Id: Ib84ed26d503a61c05933b923ec556b10cedfe140
* | audioflinger: fix wake lock acquisition checkEric Laurent2013-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | Commit e14a5d6 introduced a bug in ThreadBase::acquireWakeLock() where the wake lock acquisition return code is not initialized before being checked causing the wake lock token to be sometines not set and potential failure to release the wake lock later. Bug: 10985160. Change-Id: Iffd40e773ae3bcfec3c148a844d5dbebbf474eaf
* | Merge "Better recording wake lock accounting" into klp-devMarco Nelissen2013-10-031-11/+19
|\ \
| * | Better recording wake lock accountingMarco Nelissen2013-10-031-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Count wake lock use against the app that initiated the recording, not against the media server. b/10985160 Change-Id: Iae6e6c030b7f1c6081d9c79725d6990f60dadaaa
* | | fix volume and effect enable delay on offloaded tracksEric Laurent2013-09-301-1/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Volume: add a method to wake up the mediaserver playback thread when a volume command is received on an offloaded track. Effects: call effect chain process on offloaded playback threads asynchronously from writes to allow effect state updates while waiting for async write callback. Bug: 10796540. Change-Id: Id2747ae88783575d1d7ffd6fc86fbd054ab2c739
* | audioflinger: fix crash when starting offload threadEric Laurent2013-09-261-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing a sp to parent thread to AsyncCallbackThread() constructor causes a strong reference to be acquired on the OffloadThread inside its constructor which causes an early launch of the thread loop with unpredictable consequences. Pass a wp to parent thread instead. Also move the creation of the AsyncCallbackThread to readOutputParameters() where mUseAsyncWrite is initialized which makes more sense. Also change the type of AsyncCallbackThread parent thread to PlaybackThread instead of OffloadThread to allow a broder use of non blocking write which in theory is not limited to audio offload use case. Bug: 8174034. Change-Id: I4b093b022030cd4f5eb8b8e477333e91098a6549
* | audioflinger: fix ro.audio.silent in offload againEric Laurent2013-09-231-0/+2
|/ | | | | | | | | | | Commit 1abbdb4 was not working 100% of the times because it is possible that the offload thread loop never sleeps after being created in which case the property is never read. The loop now reads the property once when starting. Bug: 10899309. Change-Id: I2e2ca332f2d7086e59d65f6010378c4d9618ba9e
* Merge "audioflinger: implement getTimestamp() for offloaded tracks" into klp-devEric Laurent2013-09-201-0/+16
|\
| * audioflinger: implement getTimestamp() for offloaded tracksEric Laurent2013-09-201-0/+16
| | | | | | | | | | Bug: 9587132. Change-Id: Ie9d5f4cca96306d08bc9a2dbd6edd8953096702d
* | audioflinger: fix lost offload thread resume eventEric Laurent2013-09-191-27/+32
|/ | | | | | | | | | | | | | | | | It was possible that a resume request signaled by addTrack_l() while waiting for an async write callback is lost. This is because mSignalPending was not set and waitingAsyncCallback_l() would pause the thread loop before executing prepareTracks_l(). The fix consists in using signal_l() method to wake the thread loop o that mSignalPending is set. Also make sure that sleepTime is reset to 0 when resuming to make sure that we write any remaining bytes to the HAL. Bug: 10810347. Change-Id: If9a3b22cc3b9e6eb384a56c48c40e6258d0896ad
* more support for audio effect offloadEric Laurent2013-09-181-7/+23
| | | | | | | | | | | | | | | | Offloading of audio effects is now enabled for offloaded output threads. If an effect not supporting offload is enabled, the AudioTrack is invalidated so that it can be recreated in PCM mode. Fix some issues in effect proxy related to handling of effect commands to offloaded and non offloaded effects. Also fixed a bug on capture index in software Visualizer effect. Bug: 8174034. Change-Id: Ib23d3c2d5a652361b0aaec7faee09102f2b18fce
* Merge "audioflinger: fix ro.audio.silent in offload mode" into klp-devEric Laurent2013-09-141-2/+4
|\
| * audioflinger: fix ro.audio.silent in offload modeEric Laurent2013-09-131-2/+4
| | | | | | | | Change-Id: I5a1a79000d53146689b0a198cc5419c36509703f
* | audioflinger: longer offload thread standby delayEric Laurent2013-09-131-7/+22
|/ | | | | | | | | | | | | | - Increase offloaded output thread standby delay to 1 second to allow transition between tracks with going to stanby if reusing the same audio track (gapless) - Make sure pause/flush/resume sequence is sent to the HAL in the right order - Fix format display in track dump Bug: 8174034. Change-Id: I43ef6f8fdbf7427e4eff6cc2d0665d7d1463ea8a
* audioflinger: add HOTWORD audio source.Eric Laurent2013-09-101-0/+4
| | | | | | | | | | HOTWORD is a special capture audio source that uses the same audio tuning as VOICE_RECOGNITION but allows an active capture to be preempted. Bug: 10640877. Change-Id: Iea09a11cbcdbacc8d434e5230e7559dcd1b44ac0
* audioflinger: remove async write race conditionsEric Laurent2013-09-061-45/+73
| | | | | | | | | Remove possible race conditions between async callback thread and offload thread when clearing and setting the draining and write blocked flags. Bug: 8174034. Change-Id: I7af10491f39dc0e7d7414862a9d8e763daa2e2b7
* Add NBAIO_Sink::getTimestamp()Glenn Kasten2013-09-031-1/+3
| | | | | | | | | | with a real implementation in AudioStreamOutSink for dummy implementation initially in MonoPipe. Use in AudioFlinger::PlaybackThread::threadLoop_write() to keep the input to the timestamp latch up-to-date. Change-Id: I10ef277991b63bb43d55d6f3df75116ef32246cd
* audioflinger: offloaded tracks flush/pause orderEric Laurent2013-08-301-4/+6
| | | | | | | Make sure that a flush received after a pause is forwarded to the HAL after the pause. Change-Id: Ib3221f70c59f8b3dbbac20b23104f6b779b75be0
* Implement Track::getTimestamp()Glenn Kasten2013-08-291-1/+17
| | | | | | | using a new timestamp latch in PlaybackThread, and AudioTrackServerProxy::framesReleased() which returns mServer. Change-Id: I1ebfba968c773faaab95648c272fd3ebd74718d6
* RecordThread::createRecordTrack_l use flags for fast tracksGlenn Kasten2013-08-021-0/+58
| | | | | | | Look at client's request for a fast track in the flags parameter, and check whether the request can be satisfied. Change-Id: I65ddaeb1b85670fe9066076f638bfed0cda01c0d
* RecordTrack::createRecordTrack_l flags are in/outGlenn Kasten2013-08-021-1/+1
| | | | | | | | The flags are currently unused, but will be used for requesting a fast track. Making flags in/out will allow reporting back up to client that the request is denied. Change-Id: Ifbee57da3632ce130551065a426577fb97b1a68d
* Merge "Report underruns for fast tracks also"Glenn Kasten2013-08-021-8/+5
|\
| * Report underruns for fast tracks alsoGlenn Kasten2013-07-311-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression that was introduced earlier by commit 9f80dd223d83d9bb9077fb6baee056cee4eaf7e5 called "New control block for AudioTrack and AudioRecord". That commit broke underrun reporting for fast tracks. Also remove Track::mUnderrunCount, which counted the number of underrun events, and was only used by dumpsys media.audio_flinger. Now dumpsys media.audio_flinger reports the number of underrun frames, Isolated underrun-related control block accesses via the proxy, so that the server is not directly poking around in the control block. The new proxy APIs are AudioTrackServerProxy::getUnderrunFrames() and AudioTrackServerProxy::tallyUnderrunFrames(). getUnderrunFrames() returns a rolling counter for streaming tracks, or zero for static buffer tracks which never underrun, but do a kind of 'pause' at end of buffer. tallyUnderrunFrames() increments the counter by a specified number of frames. Change-Id: Ib31fd73eb17cbb23888ce3af8ff29f471f5bd5a2
* | am 6d4d8790: am b687ff9f: Merge "Fix mismatched delete/new couple"Glenn Kasten2013-08-011-2/+2
|\ \ | |/ |/| | | | | * commit '6d4d879037a495f9a4276a6996d1845594ce9090': Fix mismatched delete/new couple
| * Fix mismatched delete/new coupleAndrei V. FOMITCHEV2013-07-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In RecordThread::readInputParameters(), mRsmpInBuffer is allocated with new[] and should be freed with delete[] instead of delete. This error has been found by valgrind. Change-Id: I2f947abb658a21a7d1e61eebb99270cb37d2d147 Signed-off-by: Andrei V. FOMITCHEV <andreix.fomitchev@intel.com> Signed-off-by: David Wagner <david.wagner@intel.com> Signed-off-by: Jack Ren <jack.ren@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | Merge "Add resampler comments and fix a typo"Glenn Kasten2013-07-301-2/+5
|\ \
| * | Add resampler comments and fix a typoGlenn Kasten2013-07-301-2/+5
| | | | | | | | | | | | Change-Id: Ie071673875f663de4212eed4a4dff89d51a5a915
* | | Rename control block flags to mFlagsGlenn Kasten2013-07-301-3/+3
| | | | | | | | | | | | Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89
* | | Merge "AudioRecord and HAL input stream must be 16-bit PCM only"Glenn Kasten2013-07-301-7/+11
|\ \ \
| * | | AudioRecord and HAL input stream must be 16-bit PCM onlyGlenn Kasten2013-07-241-7/+11
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently there are 16-bit PCM assumptions in several places for capture: - resampler API - mRsmpInBuffer and mRsmpOutBuffer - RecordThread::threadLoop upmix, downmix, and resampling - possibly other places Until those assumptions are removed, this CL enforces 16-bit PCM in both client and server at all places where a format is checked. Change-Id: I08b0570bff626ad0d341804825a72c14e61b4233
* | | Rename control block server to mServer and add commentsGlenn Kasten2013-07-301-7/+8
| | | | | | | | | | | | Change-Id: Ieabd91acee92d0e84e66fbd358df5282b856306e
* | | Merge "Fix theoretical race using TrackBase::sampleRate()"Glenn Kasten2013-07-301-3/+4
|\ \ \
| * | | Fix theoretical race using TrackBase::sampleRate()Glenn Kasten2013-06-261-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In two places we assumed that TrackBase::sampleRate() would return the same value when it is called twice in the same function. This is not guaranteed; sampleRate() reads from the control block so the return value could change. To fix this, only call sampleRate() once and cache the return value to get a consistent value. This was only a theoretical race. In MixerThread::prepareTracks_l() it would have no bad effect. In TimedTrack::getNextBuffer() it could cause a real problem, but we don't currently support dynamic sample rate ratios for timed tracks. Change-Id: I8e5c33f0121fc058d1e70c2ab5e9135397d3e0b7
* | | | Remove CC_LIKELY and CC_UNLIKELY where not neededGlenn Kasten2013-07-291-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | Only keep them in performance-sensitive code Change-Id: Ib257ddd7bc39ce9896997ffae008c524ac743d01
* | | | Rename RecordThread::mInputBytes to the more generic mBufferSizeGlenn Kasten2013-07-291-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | This prepares for using it in PlaybackThreads later Change-Id: Id90a92aa6372e4b69914b0008cef07296ca5d6a3
* | | | Move members from ThreadBase to PlaybackThreadGlenn Kasten2013-07-291-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Move mNormalFrameCount and frameCountHAL(), since they're not used by record threads. Also comment which fields are updated by readParameters(). Change-Id: I5fc0a8a89cc637976f22d49271a5a3e136dab4e1
* | | | Merge "Use standard name and type for channel mask"Glenn Kasten2013-07-291-3/+3
|\ \ \ \
| * | | | Use standard name and type for channel maskGlenn Kasten2013-07-241-3/+3
| | |/ / | |/| | | | | | | | | | | | | | | | | | Former name 'channels' was ambiguous with respect to channel count. Change-Id: I716f792d95a7e0c787d27514ad6e93dbcef8a415
* | | | Merge "Simplify getParameters()"Glenn Kasten2013-07-291-12/+6
|\ \ \ \
| * | | | Simplify getParameters()Glenn Kasten2013-07-251-12/+6
| |/ / / | | | | | | | | | | | | Change-Id: Iedfeca3cd477d023c350d6d4e6eed874ee467a32
* | | | Treat mChannelCount as uint32_t consistentlyGlenn Kasten2013-07-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | mChannelCount was 8-, 16-, or 32-bits Change-Id: I2cc2fedf3e33144e5c8bbd9894763282d9217f63
* | | | Merge "Move local variable declarations to point of first use"Glenn Kasten2013-07-291-1/+1
|\ \ \ \
| * | | | Move local variable declarations to point of first useGlenn Kasten2013-07-251-1/+1
| |/ / / | | | | | | | | | | | | Change-Id: Ideb83dea2c3002651c34fa646753cba598e29e93
* | | | Merge "Move delete AudioMixer closer to point of re-allocation"Glenn Kasten2013-07-291-3/+1
|\ \ \ \
| * | | | Move delete AudioMixer closer to point of re-allocationGlenn Kasten2013-07-251-3/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | No need to delete AudioMixer before readOutputParameters Change-Id: Icafa785c9021bbe8d985e4f9527f8fc8c5e62622
* | | | Merge "Simplify RecordTrack::stop()"Glenn Kasten2013-07-291-1/+2
|\ \ \ \
| * | | | Simplify RecordTrack::stop()Glenn Kasten2013-07-251-1/+2
| |/ / / | | | | | | | | | | | | Change-Id: Ib959c1e9dc9544d12277ce11bea445118b2e0521