summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioPolicyService.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix memory leak when filtering commands in insertCommand_l()Jesper Tragardh2014-04-111-3/+11
| | | | | | | | | | | | | | | | | | | | | | | When AudioPolicyService::AudioCommandThread::insertCommand_l filters a command from the queue, the AudioCommand* is removed from the vector mAudioCommands by calling mAudioCommands.removeAt(). This will destroy the pointer and compact the vector, but not delete the AudioCommand object. This patch adds code to delete a filtered out AudioCommand and its data object mParam. However, mParam was void* and deleting a void pointer is undefined behavior according to the C++ standard. Therefore, the data classes are modified to inherit from an abstract base class with a virtual destructor. The deletion of non-filtered commands in AudioPolicyService::AudioCommandThread::threadLoop() was already correct, as each case casts mParam to the proper type before deleting. This also fixes AOSP issue 36370. Change-Id: I2b63838aff3608132aa496f964a929f78c4b6267
* Merge "AudioPolicyService: malloc/delete pair"Glenn Kasten2014-03-181-1/+1
|\
| * AudioPolicyService: malloc/delete pairYou Kim2013-09-121-1/+1
| | | | | | | | | | Change-Id: I75cd44ac0caccda9148faaa052c9e7a0c06d46d1 Signed-off-by: You Kim <you.kim72@gmail.com>
* | Merge "Frameworks: AudioFlinger: Fix effects memory leak"Glenn Kasten2014-01-101-0/+8
|\ \
| * | Frameworks: AudioFlinger: Fix effects memory leakYu Yezhong2013-10-151-0/+8
| |/ | | | | | | | | | | Patch by: csheng@marvell.com Change-Id: I4e3032fb34643902f98e8fd7c8e894b6452324c9 Signed-off-by: Yu Yezhong <yuyezhong@gmail.com>
* | fix incoming call audio start time.Eric Laurent2013-09-231-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | commit cec4abb fixing issue 6720482 had a flaw that would insert commmands at the wrong position in the audio policy service command thread queue causing other commands to be delayed more than expected. A change in track stop timing introduced by commit bfb1b83 made this issue visible when answering a call. Bug: 10860012. Change-Id: Iec769112f14e13d13b64628b808e43663e33771c
* | audioflinger: add HOTWORD audio source.Eric Laurent2013-09-101-2/+10
| | | | | | | | | | | | | | | | | | | | 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: offload playback, non-blocking writeEric Laurent2013-07-251-16/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* | Merge "Fix compile warning"Glenn Kasten2013-07-221-1/+1
|\ \
| * | Fix compile warningGlenn Kasten2013-07-191-1/+1
| | | | | | | | | | | | Change-Id: I80de4a013dc65eb7c532561438fd10e005354c03
* | | Make AudioFlinger::instantiate() more resilient when called from separate moduleGlenn Kasten2013-07-191-0/+1
|/ / | | | | | | | | Bug: 8834855 Change-Id: I4cd842cdfb09d2aaaaab9df9ac3bec6179709bd3
* | 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
* | Public API changes for audio offload support.Richard Fitzgerald2013-06-271-4/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NOTE: this does _not_ include all private member variables added to classes as part of offload support. Only public/protected functions and stubs functions/variables needed to make the changes buildable. - isOffloadSupported() added to audio policy service A stub implementation is required to build, this always returns false - setParameters() added to IAudioTrack A stub implementation is required to build, this always returns INVALID_OPERATION - CBlk flag for stream end - Change AudioSystem::getRenderPosition() to take an audio_output_t so caller can specify which output to query - Add AudioSystem::isOffloadSupported() This is fully implemented down to the AudioFlinger function AudioPolicyServer::isOffloadSupported() which is just a stub that always returns false. - Add EVENT_STREAM_END to AudioTrack interface. STREAM_END is used to signal when the hardware has actually finished playing all the data it was sent. - Add event type enumeration to media player interface AudioSink callbacks so that the same callback can be used to handle multiple types of event. For offloaded tracks we also have to handle STREAM_END and TEAR_DOWN events - Pass audio_offload_info_t to various functions used for opening outputs, tracks and audio players. This passes additional information about the compressed stream down to the HAL when using offload. For publicly-available APIs this is an optional parameter (for some of the internal and low-level APIs around the HAL interface it is mandatory) - Add getParameters() and setParameters() API to AudioTrack Currently dummy implementations. - Change AudioPlayer contructor so that it takes a set of bitflags defining what options are required. This replaces the original bool which only specified whether to use deep buffering. - Changes to StageFright class definition related to handling tearing-down of an offloaded track when we need to switch back to software decode - Define new StageFright utility functions used for offloaded tracks Currently dummy implementations. - AudioFlinger changes to use extended audio_config_t. Fills in audio_offload_info_t member if this info is passed in when opening an output. - libvideoeditor changes required to add the new event type parameter to AudioSink callback functions - libmediaplayerservice changes required to add the new event type parameter to AudioSink callback functions Change-Id: I3ab41138aa1083d81fe83b886a9b1021ec7320f1 Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Eric Laurent <elaurent@google.com>
* am 60f3f102: Merge "Prevent AudioCommands being freed before read"Glenn Kasten2013-06-201-6/+8
|\ | | | | | | | | * commit '60f3f102ba2973cc31e5c7ea00d95bbf19968e8b': Prevent AudioCommands being freed before read
| * Prevent AudioCommands being freed before readChrister Fletcher2013-06-201-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When AudioCommandThread::threadLoop process AudioCommands it was possible for it to delete a command where the posting thread still hadn't read that status from it. If a second command signaled the thread loop to continue after it had inserted a new command while the thread loop was actually waiting for the first command to report that it had read the status the thread loop would continue and delete the first command. Changed the wait condition when waiting for the calling thread to read status to use command->mCond instead of mWaitWorkCV. This way it's guaranteed that the signal to continue comes from the correct thread. Change-Id: Ia69b48cb4fdfaf8b4c83b56a197fb9f2058a92d1
| * Support querying active record sourcesJean-Michel Trivi2012-10-101-0/+12
| | | | | | | | | | | | | | | | | | Add support for querying whether there is currently a recording underway from the specified audio source. Bug 7314859 Change-Id: I986b231a10ffd368b08ec2f9c7f348d28eaeb892
| * audio policy: deprecate ro.camera.sound.forcedEric Laurent2012-10-081-4/+0
| | | | | | | | | | | | | | | | | | | | | | The volume and routing policy of AUDIO_STREAM_ENFORCED_AUDIBLE is now controlled by AudioService. Do not read ro.camera.sound.forced is not needed anymore. Bug 7032634. Change-Id: Ic0a6396fc4b6efb91cdb4dffe0c8eb035d0440bd
* | Add support for querying if a stream is active remotelyJean-Michel Trivi2013-02-111-0/+9
| | | | | | | | | | | | Bug 7485803 Change-Id: I0744374f130fd2dd0714102354cffed2fa915361
* | Don't explicitly log tidGlenn Kasten2012-11-161-8/+8
| | | | | | | | | | | | If needed, it can be obtained with adb logcat -v threadtime Change-Id: I91b3911d20f7bcfc3361db4052db21ff9181f1cf
* | Line length 100Glenn Kasten2012-11-011-2/+3
| | | | | | | | Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
* | Support querying active record sourcesJean-Michel Trivi2012-10-101-0/+12
| | | | | | | | | | | | | | | | | | Add support for querying whether there is currently a recording underway from the specified audio source. Bug 7314859 Change-Id: I986b231a10ffd368b08ec2f9c7f348d28eaeb892
* | audio policy: deprecate ro.camera.sound.forcedEric Laurent2012-10-081-4/+0
|/ | | | | | | | | | | The volume and routing policy of AUDIO_STREAM_ENFORCED_AUDIBLE is now controlled by AudioService. Do not read ro.camera.sound.forced is not needed anymore. Bug 7032634. Change-Id: Ic0a6396fc4b6efb91cdb4dffe0c8eb035d0440bd
* effect_descriptor_t const correctnessGlenn Kasten2012-07-251-2/+2
| | | | Change-Id: Iad008f20d35a18acf500f773900164552fd0c19e
* Use struct assignment instead of explicit memcpyGlenn Kasten2012-07-171-1/+1
| | | | | | for POD structs effect_descriptor_t and effect_config_t Change-Id: Ib2fc47f85fb65ed91b0abb1f87217c49b5eb571d
* Use audio_channel_mask_t more placesGlenn Kasten2012-07-101-4/+4
| | | | | | | | | | Use it in AudioSystem::getOutput(), AudioSystem::getInput(), IAudioPolicyService::getOutput(), IAudioPolicyService::getInput(), and various other places in AudioFlinger. Not done: AudioTrack and OutputDescriptor. Change-Id: I70e83455820bd8f05dafd30c63d636c6a47cd172
* audio policy: fix delayed command insertionEric Laurent2012-07-091-17/+14
| | | | | | | | | | | | | | | When inserting a delayed command in the audio policy service command thread queue, later similar commands are filtered out. In case of volume commands and delayed unmuting, this can cause a problem where a new volume command can cause the timing of a delayed unmuting command to not be honored. This change makes that a volume command gets the time stamp of any delayed command it replaces. Bug 6720482. Change-Id: I216f85ac0ea46e4a046d3483e9e9b7ffe6c34a08
* Remove acoustics from AudioSystem::getInput()Glenn Kasten2012-06-251-3/+3
| | | | Change-Id: I29fb3ee5664c1f0ee0409c1bb2be087ecca637db
* audio policy: acquire lock for volume functionsEric Laurent2012-06-191-1/+3
| | | | | | | | | | | | | | Acquire the AudioPolicyService mutex when executing setStreamVolumeIndex() and getStreamVolumeIndex(). These functions have become more complex and iterate on the list of opened outputs and it is safer to acquire the AudioPolicyService mutex to avoid concurrency with other functions. Bug 6626532. Change-Id: Ifdcbbbf13338fd9a59f694d43faa7ade143f94bf
* audioflinger: various fixes on direct outputEric Laurent2012-06-051-1/+0
| | | | | | | | | | | | Various fixes in direct output playback thread implementation: - threadLoop_write() was broken for playback threads that do not use a pipe sink. - output buffer size calculation was hard coded for stereo. - removed software volume that was implemented for PCM stereo format only: the audio HAL has to implement volume if needed for direct outputs. Change-Id: If211b4489be9af395435707b8cf0388cce1347b2
* rename audio policy output flagsEric Laurent2012-04-181-3/+3
| | | | Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
* audio policy: load audio hw modules.Eric Laurent2012-04-041-14/+66
| | | | | | | | | | | Audio HW modules are now loaded upon request from audio policy manager according to the configuration in audio_policy.conf. Removed hard coded HW module loading by AudioFlinger at init time. Added methods to IAudioFlinger and AudioPolicyInterface to control the loading of audio HW modules. Added methods to open an output or input stream on a specific hw module. Change-Id: I361b294ece1a9b56b2fb39cc64259dbb73b804f4
* audio policy: add configuration fileEric Laurent2012-04-031-1/+0
| | | | | | | | | | | removed outputs to stream mapping cache in audio system: the output for a given stream type must always be queried from audio policy manager as the cache is not always updated fast enough by audioflinger callback. removed AudioFlinger::PlaybackThread::setStreamValid() not used anymore if stream to output mapping is not cached. Change-Id: Ieca720c0b292181f81247259c8a44359bc74c66b
* Whitespace and indentationGlenn Kasten2012-03-131-25/+25
| | | | | | | | | | | | | | Fix indentation to be multiple of 4. Make it easier to search: sp< not sp < to "switch (...)" instead of "switch(...)" (also "if" and "while") Remove redundant blank line at start or EOF. Remove whitespace at end of line. Remove extra blank lines where they don't add value. Use git diff -b or -w to verify. Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
* Merge "AudioPolicyService InputDesc minor cleanup"Glenn Kasten2012-03-091-5/+3
|\
| * AudioPolicyService InputDesc minor cleanupGlenn Kasten2012-03-081-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a non-default constructor to set the mSessionId, and make mSessionId const. Remove explicit clear on mEffects - it is automatically cleared by the destructor. AudioPolicyService::setPreProcessorEnabled: - parameter is const * - use an alias instead of making a Vector copy Destructor doesn't need to be virtual since there are no subclasses. Change-Id: Ibc3c3bea8259839430b1cf5356186c7d96f1082f
* | audio policy: use audio_devices_t when appropriateEric Laurent2012-03-081-2/+4
|/ | | | Change-Id: I1b3a5879e81c789fb53d356af3d3a1ee2dca955f
* Shorten thread namesGlenn Kasten2012-02-281-2/+2
| | | | | | | | prctl(PR_SET_NAME) limits to 15 characters. Before we had names like "Binder Thread #" and the counter was cut off :-( Also remove redundant "thread" at end of name; it's always a thread. Change-Id: I1f99c2730ba0787ed9b59c15914356cddf698e2f
* Merge "Simplify code"Glenn Kasten2012-02-171-2/+1
|\
| * Simplify codeGlenn Kasten2012-02-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use DefaultKeyedVector::valueFor to avoid extra test Make local variables as local as possible No double parentheses No typedef for single use No parentheses around indirect function call No AudioFlinger:: prefix when not needed Remove unnecessary casts Remove block with only one line Saves 128 bytes Change-Id: I3a87430eeb01b81e7b81a1c38f6fdd3274ec48f3
* | Fixed possible heap corruption in EffectDescGlenn Kasten2012-02-161-19/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | "EffectDesc *effect = new EffectDesc(*effects[i]);" was relying on the default copy constructor for EffectDesc, but the default copy constructor does a member-by-member copy. This works OK for mUuid, but a member copy of mName and mParams shares pointers. This could result in heap corruption later on due to a double free. Changed to add an explicit copy constructor that does a deep copy of both mName and mParams. A malloc() and strdup() were being freed by delete, but the correct matching API for these is free(). Fortunately our current memory runtime implementation ignores the difference. Changed to use free(). EffectDesc and InputSourceDesc member fields were being torn down by the code that does delete. Changed to do the tear-down in ~EffectDesc() and ~InputSourceDesc(). Added constructor EffectDesc() with name and UUID parameters, rather than having caller fill in the object after construction. Made ~EffectDesc() and ~InputSourceDesc() non-virtual to save memory, since they have no subclasses. Change-Id: Ibb5cc2e6760d72e0c4cf537068ac4432c717bafd
* Use size_t and ssize_t with VectorGlenn Kasten2012-02-141-2/+2
| | | | | | | | Use size_t with size() and ssize_t with indexOfKey(). Exception: use ssize_t for backwards loops, and indices that are overloaded as a marker or error code. Change-Id: Ibf2a360af4539b72b09c818dda22ea2a0de92431
* Factor out and speed up permission-checking codeGlenn Kasten2012-02-131-13/+7
| | | | | | | | | | | | | Use the caching permission check for dump to save IPC. Cache getpid() to save kernel call for other permission checks. The C runtime library getpid() can't cache due to a fork race condition, but we know that mediaserver doesn't fork. Don't construct String16 on the stack. Change-Id: I6be6161dae5155d39ba6ed6228e7683e67be34ed
* Follow raw pointer and sp<> conventionsGlenn Kasten2012-02-101-2/+2
| | | | | | | | Unconditional delete for raw pointers. Use "if (sp != 0)" not "if (sp.get() != 0)" or "if (sp != NULL)". Use "if (raw != NULL)" not "if (raw)". Change-Id: I531a8da7c37149261ed2f34b862ec4896a4b785b
* Fix typos in ALOG for pid vs tidGlenn Kasten2012-02-091-1/+1
| | | | Change-Id: I6dc70f137d0ff8a86427ab8882a81886e1de0782
* Use audio_io_handle_t consistently instead of intGlenn Kasten2012-02-081-5/+5
| | | | | | | | Other: - add a comment to nextUniqueId - made ThreadBase::mId const, since it is only assigned in constructor. Change-Id: I4e8b7bec4e45badcde6274d574b8a9aabd046837
* Use 0 not NULL for sp<> and wp<>Glenn Kasten2012-02-031-9/+9
| | | | Change-Id: Id1f0c89acefaceed6cb9ca7c165fce895e46d85b
* Merge "Use audio_in_acoustics_t consistently"Glenn Kasten2012-02-031-1/+1
|\
| * Use audio_in_acoustics_t consistentlyGlenn Kasten2012-01-271-1/+1
| | | | | | | | Change-Id: I0a9dd668fb2e57b1c3ece3190588194974b99062
* | Merge "Use ToneGenerator::tone_type consistently"Glenn Kasten2012-02-031-1/+2
|\ \
| * | Use ToneGenerator::tone_type consistentlyGlenn Kasten2012-01-271-1/+2
| |/ | | | | | | | | | | | | Also remove defaults in startToneCommand(), they're not needed and the default for tone type was nonsense. Change-Id: I70fa8cee4f3dbb8c66ceb3719c8d3d2f447f05b9