summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | 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
* | | | Merge "HAL stream format for mixer output threads must be stereo 16-bit PCM"Glenn Kasten2013-07-261-0/+15
|\ \ \ \
| * | | | HAL stream format for mixer output threads must be stereo 16-bit PCMGlenn Kasten2013-07-251-0/+15
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Direct and tunnel output threads can support various HAL stream formats, included encoded. But currently there are stereo 16-bit PCM assumptions in several places for mixer and duplicating output threads: - mMixBuffer and mixBuffer() - AudioMixer including resampler - FastMixer's mixBuffer - effects - NBAIO_Format - anywhere FCC_2 is used - possibly other places Until those assumptions are removed, this CL enforces stereo 16-bit PCM in mixer and duplicating threads at the place where the HAL format is read. It was already being checked in checkForNewParameters_l(), but not in readOutputParameters(). Change-Id: Ibe344cc922743da234299097aa1bb1f54795cc9b
* | | | AudioFlinger: offload playback, non-blocking writeEric Laurent2013-07-251-158/+701
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added specialized playback thread class for offload playback, derived from directoutput thread. This thread type handles specific state transitions for offloaded tracks and offloading commands (pause/resume/drain/flush..) to audio HAL. As opposed to other threads, does not go to standby if the track is paused. - Added support for asynchronous write and drain operations at audio HAL. Use a thread to handle async callback events from HAL: this avoids locking playback thread mutex when executing the callback and cause deadlocks when calling audio HAL functions with the playback thread mutex locked. - Better accouting for track activity: call start/stop and release Output methods in audio policy manager when tracks are actually added and removed from the active tracks list. Added a command thread in audio policy service to handle stop/release commands asynchronously and avoid deadlocks with playback thread. - Track terminated status is not a state anymore. This condition is othogonal to state to permitted state transitions while terminated. Change-Id: Id157f4b3277620568d8eace7535d9186602564de
* | | Use AudioSystem::setLowRamDevice() to configure memoryGlenn Kasten2013-07-191-1/+3
| | | | | | | | | | | | | | | Bug: 9798886 Change-Id: I9321e3f369f1ed9429ae222e3926ebdeb012b8b0
* | | Make AudioFlinger::instantiate() more resilient when called from separate moduleGlenn Kasten2013-07-191-3/+1
| | | | | | | | | | | | | | | Bug: 8834855 Change-Id: I4cd842cdfb09d2aaaaab9df9ac3bec6179709bd3
* | | Fix theoretical memory leak in mConfigEventsGlenn Kasten2013-07-171-0/+6
| | | | | | | | | | | | Change-Id: I137f70676c8919661e716c33e0dd9c25c2b6285c
* | | Include what is neededGlenn Kasten2013-07-021-0/+1
|/ / | | | | | | | | | | | | Remove old includes. Header files only include other header files that they directly need themselves. Change-Id: Ic471386808d9f42ea19ccbd59cb50a5f83a89dd0
* | New control block for AudioTrack and AudioRecordGlenn Kasten2013-06-121-20/+39
| | | | | | | | | | | | | | | | Main differences between old and new control block: - removes the mutex, which was a potential source of priority inversion - circular indices into shared buffer, which is now always a power-of-2 size Change-Id: I4e9b7fa99858b488ac98a441fa70e31dbba1b865
* | am bb35be24: am 7be48189: Merge "audioflinger: fix effects on direct output ↵Eric Laurent2013-06-121-7/+5
|\ \ | |/ | | | | | | | | | | threads" into jb-mr2-dev * commit 'bb35be24239f05f59715960a93cd491a4cd3b4d6': audioflinger: fix effects on direct output threads
| * audioflinger: fix effects on direct output threadsEric Laurent2013-06-111-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PlaybackThread::addTrack_l() uses the assumption that effects are attached to a track only if the track accumulation buffer is different from the mixer thread output buffer. This is not true for direct output threads where only one track is active an only one buffer is needed. This assumption is an optimization to avoid checking for effect chains with the same session ID each time a track is processed. The optimization is not key if only one track is attached to the thread which is the case for direct outputs. Current code fails to increment the active track count in the effect chain on direct output threads when a track is started thus making the effect framework clear the mix buffer and produce silence each time the mixer runs. The fix consists in removing the optimization described above. Bug: 9324989. Change-Id: Id7a6337450ed90d326299c2ce9fc02f4b9e2fa6f
* | am d3a5b48a: am 18b46679: Merge "AudioFlinger: do not cache audio device ↵Eric Laurent2013-06-071-3/+5
|\ \ | |/ | | | | | | | | | | when 0." into jb-mr2-dev * commit 'd3a5b48a1bc4f5d6ff4472f54f909abaadd5fa39': AudioFlinger: do not cache audio device when 0.
| * AudioFlinger: do not cache audio device when 0.Eric Laurent2013-06-061-3/+5
| | | | | | | | | | | | | | | | | | AudioFlinger should not cache the audio device passed to the audio HAL when it is AUDIO_DEVICE_NONE but keep previous valid selection instead. Bug: 9323399. Change-Id: I6f9480e55a21be4115453e6a5eebc5cf2536c476
| * Remove timing jitter during startup of audioGlenn Kasten2013-04-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression introduced recently, that increased timing jitter during the startup of the FastMixer and AudioTrack callback threads. The regression was to make requestPriority() asynchronous as a way to avoid an apparent priority inversion in system_server. This means that the target thread could run briefly with the initial priority, before the new priority takes effect. This change removes the startup jitter for FastMixer, by making the requestPriority() synchronous again for that case. It doesn't matter that this restores the priority inversion involving normal mixer thread, because it happens during startup of both threads. The change also removes the startup jitter for the AudioTrack callback thread, by having the target thread check whether the requestPriority() has completed yet. If not, the target thread blocks with a timeout until the priority boost finishes. Finally, we now log an error message if the expected priority boost doesn't happen. Bug: 8698989 Change-Id: Id590e9a274b70ec1ba85b44a585ee37a22e41cbc
| * audioflinger: multiple tracks on direct outputEric Laurent2013-04-041-45/+52
| | | | | | | | | | | | | | | | | | | | | | Fix problems when multiple tracks exist on a direct output thread: when multiple tracks are active, continue to update all track states but only take into account the last track started for audio HAL volume and mixer state control. Bug 8388941 Change-Id: I57e6757286f41651dda99b11a5449e431812431b
| * Miscellaneous cleanupGlenn Kasten2013-03-041-2/+3
| | | | | | | | | | | | | | | | | | | | Abbreviation framesReady to fRdy for new systrace. Put inline const on one line. Use local copy of mState in state. Improve logging. Line length 100. Change-Id: I8201c3ce0e53fd464fd33d02544e52c342d40b68
| * Merge "media.log cleanup" into jb-mr2-devGlenn Kasten2013-03-021-13/+0
| |\