summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioSystem.cpp
Commit message (Collapse)AuthorAgeFilesLines
* AudioSystem: Fix race condition in accessing ioDescriptorsPraveen Chavan2015-10-051-4/+10
| | | | | | | | | | | | The vector mIoDescriptors can be simultaneouly modified and accessed by 2 threads. Acquire a lock while wrapping the ioDescriptor in a sp<> Bug: 24576810 Author: Haynes Mathew George <hgeorge@codeaurora.org> Change-Id: I73c79ef8eca092b500a7ead3a5ebd0bcf75f9920
* audio: several fixes in audio routing callbacksEric Laurent2015-07-101-5/+14
| | | | | | | | | | | | | | | | | | | | | | - 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
* reduce number of binder calls from mediaserverEric Laurent2015-06-261-8/+16
| | | | | | | | | | | | | | | 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
* audio flinger: do not call JAVA services until system is readyEric Laurent2015-05-201-0/+7
| | | | | | | | Wait for system ready indication form AudioService before enabling calls to scheduling service or power manager. Bug: 11520969. Change-Id: I221927394f4a08fd86c9d457e55dd0e07949f0cf
* Implement audio device callbackEric Laurent2015-05-061-62/+187
| | | | | | | | | | | | | | | | | | | | Add class AudioSystem::AudioDeviceCallback notifying AudioSystem clients upon device selection change on a given input or output thread. Maintain a list of installed callback per I/O handle in AudioSystem and call registered callbacks when an OPEN of CONFIG_CHANGED event is received on IAudioFlingerClient::ioConfigChanged(). Add methods to AudioTrack and AudioRecord to add and remove device change callbacks. Add methods to AudioTrack and AudioRecord to query currently selected device. ioConfigChanged() events now convey the audio patch describing the input or output thread routing. Fix AudioRecord failure to start when invalidation is handled by start(). Change-Id: I9e938adf025fa712337c63b1e02a8c18f2a20d39
* Merge "AudioSystem: refactor audio config cache and callbacks" into mnc-devEric Laurent2015-05-011-108/+102
|\
| * AudioSystem: refactor audio config cache and callbacksEric Laurent2015-05-011-108/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up implementation of audio configuration cache and callback events from AudioFlinger: - Define class AudioIoDescriptor for audio input and output configurations outside of AudioSystem class. - Do not use void * but an AudioIoDescriptor as argument to audio config callbacks from AudioFlinger. - Remove unused configuration events. - Move AudioSystem audio input and output cache from static singletons to members of AudioFlingerClient subclass. Change-Id: I67c196c32c09ce2756af0755ee1fe631040c3270
* | Merge "audio policy: session routes continued." into mnc-devEric Laurent2015-04-301-2/+4
|\ \
| * | audio policy: session routes continued.Eric Laurent2015-04-301-2/+4
| |/ | | | | | | | | | | | | | | | | | | | | - Clear session routes when client process dies. - Enforce the route only when the requesting session is active. - Fix requested route not working if an output mix change is required (e.g forcing to SPEAKER when the default route is USB or A2DP). - Make sure all sessions sharing the strategy with a rerouted session have the same route (needed for volume control consistency) Change-Id: I0ab347a8fb97e73e2c5965374544c5f4fe509ef1
* | Merge "AudioSystem callback for dynamic policy mix activity" into mnc-devJean-Michel Trivi2015-04-301-3/+19
|\ \ | |/ |/|
| * AudioSystem callback for dynamic policy mix activityJean-Michel Trivi2015-04-291-3/+19
| | | | | | | | | | | | | | | | | | | | Add method to AudioPolicyServiceClient for dynamic policy mix activity notification. Propagate notification to a dedicated callback. Bug 20226914 Change-Id: I37928ed38e15ea2b8fed022cccadeca8c4d6c876
* | Explicit routing in AudioRecordPaul McLean2015-04-281-2/+4
|/ | | | Change-Id: I9cc5d54883a3e5c75d553fabb619fc8e49f4f9e5
* libmedia: fix all warning, make warnings errors, use clangLajos Molnar2015-04-171-1/+0
| | | | Change-Id: Ic00d2c5d0bbb1605e96666e25c9ccc22bea6d3ff
* audio policy: add binder calls for audio source controlEric Laurent2015-04-151-0/+16
| | | | | | | Add binder methods to IAudioPolicyService to control activity of external audio sources (e.g FM tuner). Change-Id: I2008308a6a996baeae502b68a790d87281efe2ff
* AudioPolicyManager: notification of dynamic policy mix activityJean-Michel Trivi2015-04-141-0/+6
| | | | | | | | | | Implement non-stream type specific ref counting in output descriptors to keep track of mix activity. Notify audio policy client of mix activity changes. Bug 20226914 Change-Id: Iec939cb640c58056f88947b611d23b4bb6d8a11b
* Adding explicit routing API to AudioTrackPaul McLean2015-04-081-1/+2
| | | | Change-Id: I40c048c7644c46f4e4f7103875206c0785c4b1dc
* audio port: support multiple clientsEric Laurent2015-04-011-23/+68
| | | | | | Add support for more than one audio port callback client per process. Change-Id: I657c4fc28d5d2d993307551e3e69567dc60196cb
* namespace does not need a closing semicolonGlenn Kasten2015-03-231-1/+1
| | | | Change-Id: Ie8f9d42fc061f6d558f23b98414e04eb3d14b376
* Add additional info to AudioPort for enum/selection API.Paul McLean2015-02-051-3/+7
| | | | | | | | | | Add "device name" member to AudioPort. Moved unique device ID from DevicePort to AudioPort. Straighten out confusion between "name" and "address" Created string constants for Intent "extra" data keys. Combine card/address data into "address" at sender.Add additional info to AudioPort for enum/selection API. Change-Id: I1be308e12b09cd0ead9a3e9fbc9c385462299fb5
* Line length 100Glenn Kasten2014-12-301-4/+4
| | | | Change-Id: I6c8fe626a3825fa9e139319656d682a57b887c97
* audio policy: binder calls for dynamic audio policy mixesEric Laurent2014-12-091-0/+6
| | | | | | | | | Add binder calls to register and unregister dynamic mixes to AudioPolicyManager. Bug: 16009464. Change-Id: I4ef38166d0cfc88c984970969380d0cd6eb083ac
* AudioRecord: use audio attributes instead of audio source.Eric Laurent2014-11-251-8/+9
| | | | | | | | | | | | | | | | Added AudioRecord constructor with audio attributes. Replaced AudioPolicymanager::getInput() by getInputForAttr(). No new functionality for now. Also: - Fixed warnings in AudioPolicyManager - Allocate audio session ID before calling getOutputForAttr() in AudioTrack. Bug: 16006090. Change-Id: I15df21e4411db688e3096dd801cf579d76d81711
* audio policy: new getOutputForAttr() prototype.Eric Laurent2014-11-251-14/+20
| | | | | | | | | | | | | | | | | | | | | | | Update getOutputForAttr() prototype and group all logic dealing with audio attributes to stream type conversion in audio policy manager. getOutputForAttr(): - specifies the audio session (for future use) - returns a status code - receives either stream type (for legacy) or audio attributes - returns an updated streamtype Remove logic dealing with legacy stream types to attributes conversion from AudioTrack. Use correct type for audio sessions in other APIs (startOutput() ...). releaseOutput() specifies the audio session (for future use). Bug: 18067208. Change-Id: I1bfbe9626c04c7955d77f8a70aecfad2cb204817
* AudioSystem: fix cross deadlockEric Laurent2014-11-201-43/+58
| | | | | | | | | | | | | | | | | | | | Do not hold gLockAPS when calling AudioPolicyService::registerClient() in get_audio_policy_service(). registerClient() will need to acquire the AudioPolicyService mutex and if at the same time a method called from AudioPolicyService (with mutex held) calls back into AudioSystem and get_audio_policy_service() a cross deadlock occurs. Same preventive fix for get_audio_flinger(). Use a separate mutex for notification client list in AudioPolicyService. This prevents deadlocking if registerClient() is called as a consequence of AudioFlinger calling back into AudioPolicyManager while executing a method with AudioPolicyService locked Bug: 18403952. Bug: 18450065. Change-Id: Ia832e41aede8bc6c843fc615508fbdd74e0863b5
* AudioSystem: Add mutex for output cacheEric Laurent2014-11-191-37/+47
| | | | | | | | | Fix cross deadlock with AudioFlinger by adding a dedicated mutex to protect access to cached output list and parameters. Bug: 18410728. Change-Id: Ia31283b1972d8865a46e84e63695173c187eb781
* remove AudioSystem::getOutputSamplingRateForAttr()Eric Laurent2014-11-121-13/+0
| | | | | | | | It is safer to query the output sampling rate once the output have been acquired by calling getOutputForAttr(). Bug: 16009464. Change-Id: Ib561facd19fba5359a6b837d75f1a1cd2dc51b29
* Merge "Improve AudioTrack recovery from mediaserver death" into lmp-mr1-devGlenn Kasten2014-11-071-18/+30
|\
| * Improve AudioTrack recovery from mediaserver deathGlenn Kasten2014-11-051-18/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Fix race condition in handling of binder death notifications. AudioSystem has a mixture of APIs for both ordinary app clients, and the AudioFlinger and AudioPolicy services within mediaserver. Due to this mix of uses, it is possible for there to be "surprising" sequences of calls on the call stack. Previously, we used a single mutex for all global variables, but this caused a deadlock. To avoid the deadlock, we unlocked the mutex during the critical sequence of calls. But this was a a crucial place where it should have stayed locked; see Change-Id I315c1c5066f62b05e1c13b04fae1272b5fbce977 Now we use separate mutexes for the AudioFlinger, AudioPolicy, and audio port related global variables. This allows us to correctly hold each mutex throughout the atomic region, even when AudioFlinger calls AudioPolicy via AudioSystem, or vice-versa. 2. AudioSystem::clearAudioConfigCache now clears the IAudioFlinger reference. 3. Make AudioSystem::get_audio_policy_service more like get_audio_flinger. Bug: 18242291 Change-Id: I9761443d8337df5bf66d4ca2316a9fd0bd11be94
* | AudioSystem: remove obsolete method.Eric Laurent2014-11-061-15/+0
|/ | | | | Bug: 18067208. Change-Id: I9bbf9088485f5162c765ca504d9b784b956234c6
* audio: fix stream type for accessibility usageEric Laurent2014-09-251-0/+9
| | | | | | | | | Make sure that accessibility prompts are heard when a ringtone is active by forcing stream type to AUDIO_STREAM_RING when phone state is AUDIO_MODE_RINGTONE. Bug: 17558149. Change-Id: Ia3bead8052fca5cbf282c267f7b9b06014fef628
* Fix potential deadlock between AudioPolicyService and AudioSystemAndy Hung2014-09-081-1/+5
| | | | | Bug: 17109761 Change-Id: I315c1c5066f62b05e1c13b04fae1272b5fbce977
* AudioSystem: add API to query audio HW sync sourceEric Laurent2014-08-061-0/+7
| | | | | | | | | | | Add a method to query from the audio HAL the HW sync source used for a given audio session. Modify audio policy to select a direct output with HW sync when requested. Bug: 16132368. Change-Id: I03038f9188f2d389f8a5fd76a671854013a4513e
* Add sound trigger control by audio policyEric Laurent2014-08-051-0/+15
| | | | | | | | | | | | | | | | | Audio policy: - Added active capture indication to sound trigger service: recognition stops if concurrent capture is not supported. - Added generation of reserved I/O handle and session ID for utterance capture. Sound trigger service - Added sound model update callback handling. - Added service state callback - Simplified callback shared memory allocation. Bug: 12378680. Change-Id: Ib0292c2733e6df90fdae480633dd9953d0016ef1
* audio policy: pass session ID to capture activity methodsEric Laurent2014-07-281-6/+9
| | | | | | | | Indicate the audio session ID when calling getInput(), startInput(), stopInput(), releaseInput(). Bug: 12378680. Change-Id: I763793752f93e2f4e1445a5ab217c895af011038
* rename AudioSystem::newAudioSessionId()Eric Laurent2014-07-281-3/+3
| | | | | | | | | Rename AudioSystem::newAudioSessionId() to AudioSystem::newAudioUniqueId() as it can be used also for I/O handles. Bug: 12378680. Change-Id: I611ea3b5eb57a4b0774437f477ee87dc4ccc2cc2
* Add audio_input_flags_t to IAudioPolicyService::getInputGlenn Kasten2014-07-171-2/+3
| | | | Change-Id: I9f37be05f8dc7b85a8827a94e76ca0f45453e170
* libmedia: 64-bit compile warningsMark Salyzyn2014-06-201-3/+3
| | | | Change-Id: I600f062fa7148c01851023c1240c39939e648002
* AudioPolicyManager: return output for audio attributesJean-Michel Trivi2014-06-181-0/+26
| | | | | | | | | | In AudioPolicyManager, support querying an output or playback strategy for audio attributes, instead of a stream type, In AudioTrack creation, use the output returned for the track's attributes. Change-Id: I0fef05845ba676404775e2e338c10e6a96237268
* AudioSystem: remove unused stream typeJean-Michel Trivi2014-06-111-12/+6
| | | | | | | The audio stream type is not used in the getSampleRate() and getFrameCount() methods. Change-Id: I3d065ae272bd039204cd323cdab9b60460034f2d
* audio policy: add routing update client interfaceEric Laurent2014-05-291-1/+29
| | | | | | | | | | | | | Added IAudioPolicyServiceClient client binder interface for client process to receive notifications from AudioPolicyService when audio ports are added/removed or audio patches created/released. The audio patches owned by a given client are automatically released when this client binder dies. Bug: 14815883. Change-Id: I6013f6aec03b50565cffb1ad2cd1f0f8852032c5
* DO NOT MERGE - IAudioPolicyService interface extension for patch panelEric Laurent2014-05-281-0/+49
| | | | Change-Id: I0a62e5416edc41c3a0e816275085ab18a23066f1
* Merge "Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>"Glenn Kasten2014-03-261-7/+7
|\
| * Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>Glenn Kasten2014-03-261-7/+7
| | | | | | | | Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
* | Update commentsGlenn Kasten2014-03-261-1/+1
|/ | | | Change-Id: I5776313b9b49072cd666d28880f0d07cc73f827b
* Merge "Use symbol AUDIO_DEVICE_NONE from <system/audio.h>"Glenn Kasten2014-03-261-1/+1
|\
| * Use symbol AUDIO_DEVICE_NONE from <system/audio.h>Glenn Kasten2014-03-251-1/+1
| | | | | | | | Change-Id: I61f882c5e7c949bf00d3bfc745ebf3b5e1c42a58
* | Merge "Remove stream type from AudioSystem::getRenderPosition()"Glenn Kasten2014-03-261-9/+1
|\ \
| * | Remove stream type from AudioSystem::getRenderPosition()Glenn Kasten2014-03-261-9/+1
| |/ | | | | | | | | | | | | The I/O handle is never equal to AUDIO_IO_HANDLE_NONE, so the stream type is not needed. Change-Id: I1ab134a2fa379d6dd0b6167345a856a192d478f9
* | Merge "Fix uses of KeyedVector"Glenn Kasten2014-03-261-1/+1
|\ \
| * | Fix uses of KeyedVectorGlenn Kasten2014-03-251-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Constructor for AudioFlinger::mAudioHwDevs was missing, and so AudioFlinger::findSuitableHwDev_l() could return an undefined pointer if a non-0 module wasn't found. A KeyedVector of Plain Old Data (POD) element type must specify the default value in the constructor, or else the default will be undefined. Minor: - Parameter had wrong type in constructor for AudioSystem::gOutputs. - Remove obsolete AudioSystem::gStreamOutputMap. Change-Id: I9841493e018440e559d8b8b0e4e748ba2b2d365b