summaryrefslogtreecommitdiffstats
path: root/libs/audioflinger
Commit message (Collapse)AuthorAgeFilesLines
* Create base class for audio policy manager.Eric Laurent2010-01-136-1165/+1962
| | | | | | | | | | First implementations of audio policy manager in Eclair branch have shown that most code is common to all platforms. Creating AudioPolicyManagerBase base class will improve code maintainability and readability. Audio policy manager code for platforms using generic audio previously in AudioPolicyManagerGeneric is replaced by AudioPolicyManagerBase. Audio policy manager test code previously in AudioPolicyManagerGeneric is moved to AudioPolicyManagerBase. Also added a wake lock for delayed commands in AudioPolicyService.
* am 0c5cc224: am d20a55af: Merge change Iccfa50fe into eclairEric Laurent2009-12-222-25/+85
|\ | | | | | | | | | | | | Merge commit '0c5cc224b052654ee38d39effce427a47697481b' * commit '0c5cc224b052654ee38d39effce427a47697481b': Fix issue 2323920: Notification & A2DP audio stutter.
| * Fix issue 2323920: Notification & A2DP audio stutter.Eric Laurent2009-12-222-25/+85
| | | | | | | | | | | | | | Modified AudioFlinger duplicating output thread so that audio tracks are not mixed until both outputs (A2DP and hardware) have exited standby mode. This avoids to have one output far ahead of the other and audio frames dropped because the compensation mechanism cannot keep up. Also calculate the maximum wait time in OutputTrack::write() based the on smallest frame count of all output threads instead of the frame count of the thread the OutputTrack is connected to. This avoids starving the thread with the smallest frame count by waiting too long on the other thread. Since the frame count was reduced on hardware output to reduce latency the difference between A2DP and hardware outputs frame counts had become problematic. Also increased the number of overflow buffers to cope with bigger timing differences among outputs.
* | am 0a08029f: Fix issue 2306779: Runtime restart - Init failed at ↵Eric Laurent2009-12-071-12/+4
|\ \ | |/ | | | | | | | | | | | | | | android.media.ToneGenerator. Merge commit '0a08029fc9a370c6ef2a2a6fd1d800d9159b61f8' into eclair-mr2 * commit '0a08029fc9a370c6ef2a2a6fd1d800d9159b61f8': Fix issue 2306779: Runtime restart - Init failed at android.media.ToneGenerator.
| * Fix issue 2306779: Runtime restart - Init failed at ↵Eric Laurent2009-12-071-12/+4
| | | | | | | | | | | | | | | | | | | | android.media.ToneGenerator. The ToneGenerator failed to initialize because no more tracks were available in AudioFlinger mixer. All tracks were used because the duplicating output was failing to free the tracks on audio hardware output mixer when exiting due to a misplaced test on output activity: output tracks where only freed if the duplicating output was active when exiting. The fix consists in freeing the output tracks when the duplicating thread is destroyed without condition.
* | am 6d42d806: Merge change I9cc489a2 into eclairEric Laurent2009-12-072-17/+39
|\ \ | |/ | | | | | | | | | | Merge commit '6d42d80653f2c41f3e72a878a1d9a6f9693b89f7' into eclair-mr2 * commit '6d42d80653f2c41f3e72a878a1d9a6f9693b89f7': Fix issue 2304669: VoiceIME: starting and canceling voice IME yields persistent "error 8" state on future attempts and breaks voice search.
| * Fix issue 2304669: VoiceIME: starting and canceling voice IME yields ↵Eric Laurent2009-12-072-17/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | persistent "error 8" state on future attempts and breaks voice search. Fixed AudioFlinger::openInput() broken in change ddb78e7753be03937ad57ce7c3c842c52bdad65e so that an invalid IO handle (0) is returned in case of failure. Applied the same correction to openOutput(). Modified RecordThread start procedure so that a failure occuring during the first read from audio input stream is detected and causes the record start to fail. Modified RecordThread stop procedure to make sure that audio input stream fd is closed before we exit the stop function. Fixed AudioRecord JAVA and JNI implementation to take status of native AudioRecord::start() into account and not change mRecordingState to RECORDSTATE_RECORDING if start fails.
* | am 1ac56b60: Merge change Iac196e17 into eclairEric Laurent2009-12-021-5/+6
|\ \ | |/ | | | | | | | | | | Merge commit '1ac56b602aa6a1ac54c608e5a8b76f44638db23b' into eclair-mr2 * commit '1ac56b602aa6a1ac54c608e5a8b76f44638db23b': Fix issue 2292062: Audio freezes for three seconds when choosing ringtones with a headset connected and music playing.
| * Fix issue 2292062: Audio freezes for three seconds when choosing ringtones ↵Eric Laurent2009-12-011-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with a headset connected and music playing. The problem comes from a deadlock with AudioPolicyService mutex: When the second ringtone starts, this mutex is locked by AudioPolicyService::startOutput() which in turn calls setParameters() to change the output device. Audioflinger::ThreadBase::setParameters() signals the parameter change to the AudioFlinger mixer thread and waits for a condition indicating that the parameter change has been processed. At the same time, the mixer thread detects that the audio track corresponding to the first ring tone has been killed and calls its destructor. This calls AudioPolicyService::releaseOutput() which tries to lock the AudioPolicyService mutex. If this happens before the mixer thread can process the setParameters() command we are deadlocked. The deadlock ends because setParameters() uses a timeout when waiting for the condition. This regression was introduced by change 33736 fixing issue 2265163. The fix consists in calling AudioPolicyService::releaseOutput() from Track::destroy() instead of from Track destructor: as detroy() is never called from the mixer thread loop (as opposed to the destructor) the deadlock described above cannot occur.
* | Fix A2dpAudioInterface getParameters.Eric Laurent2009-11-251-1/+3
|/ | | | A2dpAudioInterface::getParameters() was prepending a ';' to the key value pair returned from underlying AudioHardwareInterface.
* Issue 2265163: Audio still reported routed through earpiece on sholesEric Laurent2009-11-192-97/+162
| | | | | | | | | | | | | This is a second attempt to fix the audio routed to earpiece syndrom. The root cause identified this time is the crash of an application having an active AudioTrack playing on the VOICE_CALL stream type. When this happens, the AudioTrack destructor is not called and the audio policy manager is not notified of the track stop. Results a situation where the VOICE_CALL stream is considered as always in use by audio policy manager which makes that audio is routed to earpiece. The fix consists in moving the track start/stop/close notification to audio policiy manager from AudioTrack to AudioFlinger Track objet. The net result is that in the case of a client application crash, the AudioFlinger TrackHandle object (which implements the remote side of the IAudioTrack binder interface) destructor is called which in turn destroys the Track object and we can notify the audio policy manager of the track stop and removal. The same modification is made for AudioRecord although no bug related to record has been reported yet. Also fixed a potential problem if record stop is called while the record thread is exiting.
* Improvements for issue 2197683: English IME key-press latency is noticeably ↵Eric Laurent2009-11-112-70/+103
| | | | | | | | | higher on passion than sholes This change goes with a kernel driver change that reduces the audio buffer size from 4800 bytes (~27ms) to 3072 bytes (~17ms). - The AudioFlinger modifcations in change 0bca68cfff161abbc992fec82dc7c88079dd1a36 have been removed: the short sleep period was counter productive when the AudioTrack is using the call back thread as it causes to many preemptions. - AudioFlinger mixer thread now detects long standby exit time and in this case anticipates start by writing 0s as soon as a track is enabled even if not ready for mixing. - AudioTrack::start() is modified to start call back thread before starting the IAudioTrack so that thread startup time is masked by IAudioTrack start and mixer thread wakeup time.
* AudioFlinger: delete Track object when createTrack() fails due to lack of ↵Eric Laurent2009-11-091-1/+1
| | | | | | tracks in AudioMixer. This problem was encountered as a side effect of issue 2245298.
* More log for issue 2242381.Eric Laurent2009-11-074-17/+120
| | | | Added more log in system dump for AudioFlinger and AudioPolicyService to help debug issue 2242381 and other issues where the audio driver hangs.
* Log for issue 2203561.Eric Laurent2009-11-034-3/+230
| | | | | Implemented AudioPolicyService dump(). Added detailed dump for AudioPolicyManageriGeneric when AudioPolicyService is dumped.
* Fix issue 197683: English IME key-press latency is noticeably higher on ↵Eric Laurent2009-11-021-3/+6
| | | | | | | | | | passion than sholes. Part 2. Reduce sleep time in AudioFlinger mixer thread when no data has been written to output to speed up startup time when exiting standby. The rest of the modifications for this issues is in kernel driver: commit 0dbb0ee136ed8de757df1ae26d84556c1751deae for buffer size modification from 8192 to 4800 bytes. Another kernel improvement that is not submitted yes will reduce delay when audio output is exiting standby.
* Fix issue 2192181: AudioFlinger must provide separated methods to set ↵Eric Laurent2009-10-214-34/+73
| | | | | | | VOICE_CALL stream volume and down link audio volume. Added setVoiceVolume() method to AudioSystem, AudioFlinger, IAudioFlinger, AudioPolicyService. Removed call to AudioHardwareInterface::setVoiceVolume() from AudioFlinger::setStreamVolume().
* Fix issue 2174002: After rejecting Call when device ringtone is mute and ↵Eric Laurent2009-10-082-5/+33
| | | | | | | | playing music, audio is not transfered to BT device. Added a workarouond to request the A2DP output standby directly to audio hardware when the sink is suspended as it seems that the suspend request often fails. Also take into account resume requests received while a suspend request is pending.
* Fix issue 2139634: DTMF tones on Sholes popping, hissing (audio latency too ↵Eric Laurent2009-10-062-59/+81
| | | | | | | | | | high). This change is a complement to the main fix in kernel driver for the same issue (partner change #1250). It removes clicks sometimes heard after the end of the tones while audio flinger is sending 0s to the audio output stream. The problem was that the sleep time between two writes was more than the duration of one audio output stream buffer which could cause some underrun. Also fixed a recent regression in ToneGenerator that made that the end of previous tone was repeated at the beginning of current one under certain timing circumstances when the maximum tone duration was specified.
* Fix issue 2153835: AudioFlinger: setParameters() can remain stuck if output ↵Eric Laurent2009-09-301-14/+23
| | | | | | | | thread is terminated. Wait for the parameter set completed condition with a time out in ThreadBase::setParameters(). Also lock AudioFlinger mutex before accessing thread list in AudioFlinger::setParameters() and keep a strong reference on the thread being used in case it is exited while processing the request.
* Reduce the log spew from AudioFlinger due to a certain device that can't ↵Dave Sparks2009-09-301-4/+16
| | | | meet latency timing. Bug 2142215.
* Fix issue 2116700: Ringer screwy while connected over Bluetooth.Eric Laurent2009-09-221-97/+106
| | | | | | There was a regression introduced in AudioFlinger by change 24114 for suspended output: The suspended output was not reading and mixing audio tracks. When the phone is ringing, the A2DP output is suspended if the SCO headset and A2DP headset are the same. As the ringtone is played over the duplicated output, the fact that the A2DP output was not reading data was causing the hardware output to be stalled from time to time.
* Fix issue 2127371: Possible race condition in AudioFlinger::openRecord() ↵Eric Laurent2009-09-172-6/+18
| | | | | | when a Track is being destroyed. The fix consists in locking AudioFlinger::mLock mutex in the TrackBase destructor before clearing the strong pointer to the shared memory client. The mutex is not locked in removeclient() any more which implies that we must make sure that the Client destructor is always called from the TrackBase destructor or that we hold the mLock mutex before calling deleting the Client.
* Fix issue 2123668: Class scope typo in AudioFlinger.cpp.Eric Laurent2009-09-161-8/+8
|
* Fix issue 2118464: cannot play ring tones and notifications after ↵Eric Laurent2009-09-152-18/+14
| | | | | | | | | | disconnecting BT headset while in call. The problem comes from the fact that when the duplicated output is closed after BT headset disconnection, the OUTPUT_CLOSED notification is not sent to AudioSystem. Then the mapping between notification stream and duplicated output cached in AudioSystem is not cleared and next time a notification is played, the duplicated output is selected and the createTrack() request is refused by AudioFlinger as the selected output doesn't exist. The notification is ignored by AudioFlinger because when it is sent by the terminating playback thread, the thread has already been removed from the playback thread list. The fix consists in sending the notification in closeOutput() and not when exiting the playback thread. The same fix is applied to record threads.
* Fix issue 2115450: a2dp thread is started, even though we are only connected ↵Eric Laurent2009-09-141-2/+3
| | | | | | | to headset and not playing music. This is due to a regression introduced by change 24114: when no audio tracks are ready for mixing, 0s are written to audio hardware. However this should only happen if tracks have already been mixed since the audio flinger thread woke up. Also do not write 0s to audio hardware in direct output threads when audio format is not linear PCM.
* Fix issue 2107584: media server crash when AudioFlinger fails to allocate ↵Eric Laurent2009-09-091-22/+27
| | | | | | | | memory for track control block. AudioFlinger: verify that mCblk is not null before using it in Track and RecordTrack contructors. IAudioFlinger: check result of remote transaction before reading IAudioTrack and IAudioRecord. IAudioTrack and IAudioRecord: check result of remote transaction before reading IMemory.
* Fix issue 1992233: DTMF tones on Sholes is really long.Eric Laurent2009-09-081-55/+63
| | | | | Add a parameter to ToneGenerator.startTone() allowing the caller to specify the tone duration. This is used by the phone application to have a precise control on the DTMF tone duration which was not possible with the use of delayed messaged. Also modified AudioFlinger output threads so that 0s are written to the audio output stream when no more tracks are ready to mix instead of just sleeping. This avoids an issue where the end of a previous DTMF tone could stay in audio hardware buffers and be played just before the beginning of the next DTMF tone.
* fix issue 2096657: Sholes: residue shutter sound heard ONCE while taking a ↵Eric Laurent2009-09-031-6/+7
| | | | | | | picture AFTER the volume is turned off. Do not ramp volume if the first frame of a track is processed after the track was stopped. In the case of very short sounds, the track stop request can be received by AudioFlinger just after the start request before the first frame is mixed by AudioMixer. In this case, the track is already in stopped state and initial volume is applied with a ramp for the first frame processed which should not be the case: initial volume change is always applied immediatelly.
* Fix issue 2091594: music chirp after disconnecting A2DP.Eric Laurent2009-09-011-1/+4
| | | | | In AudioFlinger::MixerThread::putTracks(), change the mFillingUpStatus flag to FS_FILLING for active tracks so that mute request is executed without ramping volume down when the track is moved from A2DP to hardware output. Also modified AudioFlinger::setStreamOutput() so that the notification of the change is sent only once to AudioSystem.
* Fix issue 2085690: AudioFlinger must properly terminate the input and output ↵Eric Laurent2009-08-311-2/+11
| | | | | | threads when destroyed. Call closeInput() for all inputs and closeOutput() for all outputs before deleting audio hardware in AudioFlinger destructor.
* Fix issue 2045911: Camera Shutter tone does not play correctly while ↵Eric Laurent2009-08-272-75/+201
| | | | | | listening to music. Add the possibility to delay routing and volume commands in AudioPolicyClientInterface. The delay is not blocking for the caller.
* Workaround for issue 2046783.Eric Laurent2009-08-122-2/+13
| | | | | Apparently the problem is caused by the fact that A2dpAudioStreamOut::standby() calls a2dp_stop() after the headset has been powered down. The workaround consists in indicating to A2DP audio hardware that a close request is pending and that stanby() must be bypassed.
* Fix issue 2046140: master: media_server crash when powering down A2DP ↵Eric Laurent2009-08-112-25/+30
| | | | | | | | | | headset while a ringtone is playing. This is because the AudioFlinger duplicating thread is closed while the output tracks are still active. This cause the output tracks objects to be destroyed at a time where they can be in use by the destination output mixer. The fix consists in adding the OutputTrack to the track list (mTracks) of its destination thread so that a strong reference is help during the mixer processed and the track is detroyed only when safe by destination thread. Also added detection of problems when creating the output track (e.g. no more tracks in mixer). In this case the output track is not added to output track list of duplicating thread.
* Fix issue 2043314: Recorded audio is choppy.Eric Laurent2009-08-111-1/+1
| | | | Fixed cut/paste error causing constant reset of current frame index in input buffer.
* Limit AudioFlinger mixer track sampling rate.Eric Laurent2009-08-101-0/+4
| | | | When changing the audio output stream sampling rate with setParameters() make sure that all tracks have a sampling rate less or equal to 2 times the new output sampling rate.
* AudioService now differentiates BT headsets and car kits.Eric Laurent2009-08-072-4/+4
| | | | | The BT headset detection now makes the difference between car kits and headsets, which can be used by audio policy manager. The headset connection is also detected earlier, that is when the headset is connected and not when the SCO socket is connected as it was the case before. This allows the audio policy manager to suspend A2DP output while ringing if a SCO headset is connected.
* Fix problem in AudioFlinger closeOutput and closeInput.Eric Laurent2009-08-071-7/+12
| | | | | | | | There was no garanty that the corresponding thread destructor had been already called when exiting the closeOutput() or closeInput() functions. This contructor could be called by the thread after the exit condition is signalled. By way of consequence, closeOutputStream() could be called after we exited closeOutput() function. To solve the problem, the call to closeOutputStream() or closeInputStream() is moved to closeOutput() or closeInput().
* Improved unit test code for Audioflinger.Eric Laurent2009-08-074-37/+183
|
* Fix lockup in audio flinger threadbase setParameters.Eric Laurent2009-08-072-24/+47
| | | | | | | | | The function checkForNewParameters_l() is called with the ThreadBase mutex mLock locked. In the case where the parameter change implies an audio parameter modification (e.g. sampling rate) the function sendConfigEvent() is called which tries to lock mLock creating a deadlock. The fix consists in creating a function equivalent to sendConfigEvent() that must be called with mLock locked and does not lock mLock. Also added the possibility to have more than one set parameter request pending.
* Merge change 9660Android (Google) Code Review2009-08-071-1/+1
|\ | | | | | | | | * changes: Fix problem in A2DP interface closeOutputStream().
| * Fix problem in A2DP interface closeOutputStream().Eric Laurent2009-08-041-1/+1
| | | | | | | | If the output stream handler passed was not the A2DP output stream, the request was ignored instead of being forwarded downstream to hardware interface.
* | Merge change 9653Android (Google) Code Review2009-08-073-4/+16
|\ \ | | | | | | | | | | | | * changes: Fix getParameters() default implementation.
| * | Fix getParameters() default implementation.Eric Laurent2009-08-043-4/+16
| |/ | | | | | | Do not return empty string but key value pairs with empty values.
* | Fix issue 2001214: AudioFlinger and AudioPolicyService interfaces should not ↵Eric Laurent2009-08-075-150/+161
|/ | | | | | | use pointers as handles to inputs and outputs. Use integers instead of void* as input/output handles at IAudioFlinger and IAudioPolicyService interfaces. AudioFlinger maintains an always increasing count of opened inputs or outputs as unique ID.
* Merge change 8987Android (Google) Code Review2009-07-291-0/+1
|\ | | | | | | | | * changes: Fix firestone build
| * Fix firestone buildMarco Nelissen2009-07-291-0/+1
| |
* | Fix issue 2004229: DTMF tones play through earpiece (G1).Eric Laurent2009-07-281-1/+1
|/
* Fix the build for BOARD_USES_GENERIC_AUDIO optionEric Laurent2009-07-251-3/+2
|
* Fix issue 2001204: libaudiopolicy.so and libaudiopolicygeneric.so libraries ↵Eric Laurent2009-07-244-55/+20
| | | | must be pre-linked.