summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
Commit message (Collapse)AuthorAgeFilesLines
* audioflinger: implement pause/resume for direct outputsEric Laurent2014-12-161-0/+5
| | | | | | | | | | | | | | | | | Extend pause/resume support to direct output threads (was only for offload threads). If the HAL implements pause/resume, track pause/resume is forwarded to the HAL. Pause, flush, resume sequence is respected by executing the HAL calls in the playback thread (same as offload). Make sure the track flags on client side are consistent with the flags on server side. Bug: 17883772. Change-Id: I89b360d69818f7a9204bd36e3ec63a79e106ecf1
* audio policy: add support for custom mixesEric Laurent2014-12-091-0/+8
| | | | | | | | | | | | | | | | | Add support for custom mixes in AudioPolicyManager. Two methods are added to register or unregister a list of custom mixes with their attributes and format. getOutputForAttr() and getInputForAttr() first look for a match in registered mixes before defaulting to normal output/input selection Remote submix device connection disconnection now takes address into account to identify the correspnoding custom mix. Bug: 16009464. Change-Id: I3f1c2a485a0fb71b1f984ed0adc9b68aa971e408
* Track volume should be maintained even if track is restoredseunghak.han2014-12-051-1/+5
| | | | | | | | If track is restored when it set its volume to a non-unity value (such as mute), the volume was forced to unity again. Now, the previous volume is restored. Bug: 18570664 Change-Id: I79f34c6c7d6f535baba813fd3b8ba8e55cac8ad7
* AudioRecord: use audio attributes instead of audio source.Eric Laurent2014-11-251-1/+5
| | | | | | | | | | | | | | | | 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
* Merge "audio policy: new getOutputForAttr() prototype." into lmp-mr1-devEric Laurent2014-11-261-177/+25
|\
| * audio policy: new getOutputForAttr() prototype.Eric Laurent2014-11-251-177/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Fix AudioTrack loop mode to play audio from buffer start" into ↵Andy Hung2014-11-251-2/+1
|\ \ | |/ |/| | | lmp-mr1-dev
| * Fix AudioTrack loop mode to play audio from buffer startAndy Hung2014-11-241-2/+1
| | | | | | | | | | Bug: 18217633 Change-Id: Ica77acf0a32832d9b04eb657ef2f4f5329f8fbda
* | audio: new routing strategies and stream typesEric Laurent2014-11-211-1/+1
|/ | | | | | | | | | | | | Added new routing strategies and stream type for internal use by audio policy manager and audio flinger: - One for accessibility to allow different routing than media - One for re-routing (remote submix) in preparation of dynamic policies - Added stream type for "internal" audio flinger tracks used for audio patches and duplication. Bug: 18067208. Change-Id: I88f884b552e51e4a49c29125e5a1204cf58ff434
* audio policy: do not prevent routing to A2DP when suspended.Eric Laurent2014-11-171-0/+5
| | | | | | | | | | | | | | | | | Allow A2DP sink selection even if A2DP is suspended. It is not because use of A2DP is temporarily disabled by SCO selection that the policy rule routing a given use case to A2DP should be altered. The source will be routed to A2DP but it will remain silent until suspend condition is cleared which is the purpose of suspend mode. Also make sure that accessibility prompts are audible while in call by forcing stream type to STREAM_VOICE_CALL. Fix inconsistent logic between AudioTrack::setStreamTypeFromAttributes() and AudioPolicyManager::getStrategyForAttr() Bug: 18095151. Change-Id: I1c75dd8288ed3dd494eb942060eac9c9660dca50
* remove AudioSystem::getOutputSamplingRateForAttr()Eric Laurent2014-11-121-15/+15
| | | | | | | | It is safer to query the output sampling rate once the output have been acquired by calling getOutputForAttr(). Bug: 16009464. Change-Id: Ib561facd19fba5359a6b837d75f1a1cd2dc51b29
* Improve AudioTrack recovery from mediaserver deathGlenn Kasten2014-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "audio: fix talkback why alarm is playing" into lmp-mr1-devEric Laurent2014-11-041-4/+11
|\
| * audio: fix talkback why alarm is playingEric Laurent2014-11-031-4/+11
| | | | | | | | | | | | | | | | | | Convert attributes usage "assistance accessibility" to a stream type guarantying that the prompt is audible and not muted by policy manager. Bug: 17994328. Change-Id: I89f53f2ce84b499b859336c0a1a3a0332ee670f5
* | Support speaker routing for FLAG_BEACONJean-Michel Trivi2014-10-311-2/+10
|/ | | | | | | | | | | | | | | | | | | | Add support for routing audio stream to the speaker when audio attributes carry the FLAG_BEACON value: - associate streams with FLAG_BEACON to the up-to-now unused STREAM_TTS ("Transmitted Through Speaker"). The remapping happens in AudioTrack. - AudioPolicyManager: define new strategy for handling the Beacon behavior, that only goes to speaker. Define new volume curves for STREAM_TTS that are not silence only for the speaker device category. Keep ref count of other streams and never play Beacon streams when anything else is playing: either don't start playback if something else is playing, or unmute STREAM_TTS when it's allowed to play and mute when it's done. - Take into account muting latency when starting an output. Bug 15415971 Change-Id: I26539c7ec1a486accd85bbeb1623e9c7d3a1192f
* Fix AudioTrack retrograde getPosition when restoring tracksAndy Hung2014-10-171-1/+4
| | | | | | | | | | | mReleased represents the number of frames written to the track, but was cleared on start() causing a mismatch if the client wrote to the track before starting. Moved the clearing to entering the STATE_STOPPED or STATE_FLUSHED state. Bug: 18017947 Bug: 18022276 Change-Id: I3788c98c4c3c4d9cc004378432797b3f3138e22e
* AudioTrack: fix AudioTrackThread crash upon exitEric Laurent2014-10-071-0/+3
| | | | | | | | | | | In case of error during createTrack_l(), there is a possibility that a newly created AudioTrackThread is resumed by requestExit() just after entering the Thread class _threadLoop() but before entering the class threadLoop(). In this case, processAudioBuffer() is executed once with mCblk == 0 and we assert. Bug: 17894033. Change-Id: I93d0d0d4dbf14bcb88dad23e6ad49d2ecd47badd
* audio: fix stream type for accessibility usageEric Laurent2014-09-251-1/+8
| | | | | | | | | 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
* Reduce log spam from getTimestamp errorsGlenn Kasten2014-09-191-1/+1
| | | | | Bug: 17576481 Change-Id: I07d99e7c42b7d4f0994b5a6d9c9fe8eb29fbbe40
* Fix AudioTrack offloaded timestamp handling.Andy Hung2014-09-171-5/+93
| | | | | | | | | | getTimestamp for offloaded tracks now returns WOULD_BLOCK for situations where the timestamp is unavailable due to the previous track still flushing or the timestamp is stale. It is fixed for normal playback conditions. Bug: 14659809 Bug: 17428188 Change-Id: Ic9ec07ccabc604236979769db5c4ea2dec252660
* Clean up AudioTrack position and timestamp handlingGlenn Kasten2014-09-111-18/+73
| | | | | | | | | | | | | | | | | | | Replace epoch concept by observing and accumulating server delta positions. The advantage of using server deltas instead of absolute values is that they (1) are not sensitive to 32-bit wraparound, (2) are not sensitive to server behavior for stop(), and (3) prepare for future 64-bit client positions without requiring 64-bit positions on server. Add comments to AudioTrack::getTimestamp() and friends that the timestamp output parameter is undefined on error. Don't allow getTimestamp to return a negative frame position after stop(). Accumulate the client released frames, which may be useful for a future API. Bug: 11815245 Change-Id: I652940fa2db2f34a78c012a3ead0d9204fa29c6e
* Extend downsampling ratios greater than 2:1Andy Hung2014-08-111-4/+4
| | | | | | | | | Also improve robustness to choice of sampling rate or buffer size such that increasing either by 10x does not cause overflow. Bug: 12979141 Bug: 15933066 Change-Id: If7989bd745d1bee3bdf811b8b7c978543ccafb65
* Support for audio attributes on audio output of media playerJean-Michel Trivi2014-07-011-5/+7
| | | | Change-Id: Iae4995c98e64add1ab9e6c8ae6501515032755f5
* libmedia: 64-bit compile warningsMark Salyzyn2014-06-201-14/+15
| | | | Change-Id: I600f062fa7148c01851023c1240c39939e648002
* AudioTrack: add support for compressed audioEric Laurent2014-06-191-15/+52
| | | | | | | | | Add support for compressed audio playback by use of an AudioTrack attached to a direct output thread. Bug: 9428304. Change-Id: I4a61be9cf0e31003ca85935d6e0ee38ca8192e03
* AudioPolicyManager: return output for audio attributesJean-Michel Trivi2014-06-181-9/+6
| | | | | | | | | | 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
* AudioTrack construction with audio attributesJean-Michel Trivi2014-06-171-10/+163
| | | | | | | | | | | | Store audio attributes in AudioTrack class. When an AudioTrack is "set" with non null audio attributes, derive a stream type that reflects the attributes. When an AudioTrack is "set" without attributes, and only has a stream type, derive default audio attributes. Change-Id: I322b91fa9a7e193118960c5e78cdddd85d66f9ad
* Merge "AudioSystem: remove unused stream type"Jean-Michel Trivi2014-06-121-5/+5
|\
| * AudioSystem: remove unused stream typeJean-Michel Trivi2014-06-111-5/+5
| | | | | | | | | | | | | | The audio stream type is not used in the getSampleRate() and getFrameCount() methods. Change-Id: I3d065ae272bd039204cd323cdab9b60460034f2d
* | force command flush after releasing a reference to shared memoryEric Laurent2014-06-131-1/+4
|/ | | | | | | | | | | | | After releasing a reference to a shared memory interface, IPCThreadState::self()->flushCommands() must be called to ensure that the corresponding reference is also cleared immediately in the remote process. Otherwise the binder implementaiton will not push the clear systematically causing the memory region not to be freed. See issues 10711502 and 2801375. Bug: 14057166. Change-Id: If55f36f00d452d6cf00cf83bd2fba1c8f3abcb57
* Merge "Use new channel count functions for audio masks"Andy Hung2014-05-191-1/+1
|\
| * Use new channel count functions for audio masksAndy Hung2014-05-161-1/+1
| | | | | | | | | | Change-Id: Ia658ab4b6320d19fdb50f123c930918724ff0ef3 Signed-off-by: Andy Hung <hunga@google.com>
* | Pass stereo gains as packed minifloatGlenn Kasten2014-05-191-5/+8
|/ | | | | | | | | | This will allow (eventually) a greater dynamic range for gains. However there are still a few remaining places in effects and mixer that will also need to be changed in order to get the full benefit. Also fixes a minor bug: was not checking for NaN in AudioTrack C++. Change-Id: I63bce9e82e0a61546d8ff475fb94bcb700d99c96
* Add client side support for more AUDIO_FORMAT_PCM_*Glenn Kasten2014-05-071-7/+19
| | | | | | | As much as possible, the checks for specific formats are done on server side. The only exception is 8-bit, which needs a client side workaround. Change-Id: I52fe086c039460c8dac009de03b67eb54c56a836
* Fix bug for direct track with PCM != 16-bitGlenn Kasten2014-05-021-1/+2
| | | | | | | | | | | | The AUDIO_FORMAT_PCM_8_BIT format was being converted to AUDIO_FORMAT_PCM_16_BIT on client side even for direct tracks. That conversion was incorrect; it should only be done for mixed tracks. Also remove checks for specific PCM formats in the generic part of server side of createTrack. Those format checks should only be done by the thread. This will allow direct tracks for PCM 8-bit, PCM 24-bit, etc. Change-Id: If5b9fd79f8642ed93e2aeabcaf4809b2ed798978
* Use AUDIO_INTERLEAVE_* constantsGlenn Kasten2014-04-301-1/+1
| | | | Change-Id: I6609fa75c9a57fc4ca3887d626a2f4fb8b6593a1
* Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>Glenn Kasten2014-03-261-5/+5
| | | | Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
* Merge "Use symbolic constants from <system/audio.h>"Glenn Kasten2014-03-261-6/+6
|\
| * Use symbolic constants from <system/audio.h>Glenn Kasten2014-03-251-6/+6
| | | | | | | | | | | | | | | | AUDIO_INTERLEAVE_* AUDIO_STREAM_MIN AUDIO_SESSION_ALLOCATE Change-Id: I31dd6f327204685e50716079ce21c4ba206dff11
* | Merge "Remove streamType parameter from AudioSystem::getLatency()"Glenn Kasten2014-03-261-1/+1
|\ \
| * | Remove streamType parameter from AudioSystem::getLatency()Glenn Kasten2014-03-251-1/+1
| |/ | | | | | | Change-Id: Ie7346e93436ddc215cad7d16be555dcb6c277d54
* | Remove dead codeGlenn Kasten2014-03-261-20/+0
|/ | | | Change-Id: I0878d11451c7bbbf96b59f5fe0cd97ba1f033aa9
* Remove name output parameter from createTrackGlenn Kasten2014-03-141-3/+1
| | | | | | | It was only used for one log. A better solution will be a per-track unique ID. Change-Id: Ia440e02ae4a5a4019a9a2d08970e1ee93ac4c3a3
* Merge "AudioTrack non-blocking write"Jean-Michel Trivi2014-03-111-2/+3
|\
| * AudioTrack non-blocking writeJean-Michel Trivi2014-03-031-2/+3
| | | | | | | | | | | | Bug 7531968 Change-Id: I6d0e79fa8cab5b6eb36bcc34977f4cf0d7eec8ea
* | Fix freeze on pauseMarco Nelissen2014-03-101-1/+1
| | | | | | | | | | | | | | isOffloaded() tries to lock mLock again. We should be calling isOffloaded_l() b/13394633 Change-Id: I155be6fee937f894d8e6c974e593223ab6014ade
* | Merge "Simplify AudioTrack stream end and fix race"Glenn Kasten2014-03-071-17/+15
|\ \
| * | Simplify AudioTrack stream end and fix raceGlenn Kasten2013-09-291-17/+15
| | | | | | | | | | | | | | | Bug: 10994052 Change-Id: Ib2e38e7a600bcffef8cbc68c1722e40fbbc7ea67
* | | AudioTrack: When paused, return cached playback positionHaynes Mathew George2014-03-061-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An offload output can be re-used between two audio tracks having the same configuration. A timestamp query for a paused track while the other is running would return an incorrect time. To fix this, cache the playback position on a pause() and return this time when requested until the track is resumed. Bug: 12826612. Change-Id: I324112ea9827e52fff53ef44cd8513c8d85a0bc4
* | | Merge "Make openRecord_l more like createTrack_l for fast tracks: part 1"Glenn Kasten2014-02-281-2/+2
|\ \ \