summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Clean up channel count and channel maskGlenn Kasten2012-11-191-12/+8
| | | | | | | | Channel count is uint32_t. Remove redundant mask parameter to AudioTrack::createTrack_l() and AudioRecord::openRecord_l(). Change-Id: I5dc2b18eb609b2c0dc3091994cbaa4628062c17f
* Merge ""if" statements use curly braces per media style"Glenn Kasten2012-11-161-2/+4
|\
| * "if" statements use curly braces per media styleGlenn Kasten2012-11-161-2/+4
| | | | | | | | Change-Id: I130e7849fd1da7a0b7fe56c3c53919d26e3843b8
* | Don't use control block frame count after createGlenn Kasten2012-11-161-4/+4
|/ | | | | | This is part of a series to clean up the control block. Change-Id: I7f4cb05aef63053f8e2ab05b286d302260ef4758
* Use size_t for frame countsGlenn Kasten2012-11-151-6/+12
| | | | | | Also fix typo: bufferCount should be frameCount. Change-Id: Ibed539504db75ef99dc21c8ff1bf2987122063a5
* Use uint32_t for sample rateGlenn Kasten2012-11-141-2/+2
| | | | Change-Id: Ie240b48fb54b08359f69ecd4e5f8bda3d15cbe80
* Simplify AudioRecord::restoreTrack_l()Glenn Kasten2012-11-131-49/+44
| | | | | | | | | | | | | | Finish removing CBLK_RESTORING and CBLK_RESTORED from control block flags, and remove constant RESTORE_TIMEOUT_MS. Also minor cleanup: - Cache mCblk in local variable cblk and make cblk allocatable in a register. - Use "iMem" for sp<IMemory>. - Add missing error log to AudioRecord; it was already in AudioTrack. This is part of a series to clean up the control block. Change-Id: Ia5f5ab4763c392bc06a45851b167ddaee29e3455
* Move frame size out of the control blockGlenn Kasten2012-11-121-11/+9
| | | | | | This is part of a series to clean up the control block. Change-Id: Ifab1c42ac0f8be704e571b292713cd2250d12a3f
* Move buffers pointer out of the control blockGlenn Kasten2012-11-081-2/+2
| | | | | | This is part of a series to clean up the control block. Change-Id: Ie474557db7cb360f2d9a0f11600a68f5a3d46f07
* Remove CBLK_DIRECTION from control block flagsGlenn Kasten2012-11-071-5/+4
| | | | | | This is part of a series to clean up the control block. Change-Id: I0265fece3247356b585d4d48fbda6f37aea8a851
* Removed unused fields in AudioRecord::BufferGlenn Kasten2012-11-061-3/+0
| | | | Change-Id: I89fc6d8f695b48516d956b0a9a4a43d408f369f9
* Simplify control block flag namesGlenn Kasten2012-11-051-11/+11
| | | | | | Use only one symbol per flag Change-Id: Ia3582e2134abd60c896d11337face65383e79c7c
* Line length 100Glenn Kasten2012-11-011-2/+4
| | | | Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
* AudioRecord: Fix minimum frame count calculation.Eric Laurent2012-09-061-1/+1
| | | | | | | AudioRecord::set() was calling getMinFrameCount() with a channel count instead of a channel mask. Change-Id: Iabace7686426430fd53deac0c71b0c36aa64171c
* AudioRecord lockingGlenn Kasten2012-07-171-14/+31
| | | | | | | | | | | | | | | | Fix race conditions for EVENT_MARKER and EVENT_NEW_POS callbacks. Marker and new position update fields are protected by lock. getSampleRate() doesn't need a lock because it reads from shared memory control block. Enforce that the parameter passed with EVENT_MARKER and EVENT_NEW_POS cannot not be changed by the callback handler, and will not change during the call by another thread. Session ID should never change; log if it does. Change-Id: Ia2c63cf1a71b10bb06c37981bd76437f83fffa91
* AudioRecord::stop() return voidGlenn Kasten2012-07-131-3/+1
| | | | | | like AudioTrack::stop() Change-Id: Iab62f4665151345f1ad5874c97a21d1a331f0154
* AudioRecord client threading cleanupGlenn Kasten2012-07-131-55/+62
| | | | | | | | | | | | | | | | | | | Rename ClientRecordThread to AudioRecordThread to be more similar to AudioTrack naming. Only create the thread once, and use resume() and pause() for start() and stop(). This will allow us to have a known client callback thread tid that we can pass to AudioFlinger before start(). mActive: Made mActive a bool not int. mActive is protected by mLock; volatile is meaningless. Fixed a few places where mActive was accessed without a lock: - stopped() - processAudioBuffer() These aren't used internally, so no need for _l() versions. Change-Id: I4b8a5c90f3a22d3894b344564cb1c5aef4f1fda2
* getMinFrameCount error handlingGlenn Kasten2012-07-131-0/+5
| | | | | | | | Convention is for "get" APIs that directly return status_t and indirectly return a value via a pointer, to return BAD_VALUE if the pointer is NULL. Also indirectly return 0 for other errors. Change-Id: I1599f20ecb26e9723f9fb384ffbf911ff3a2ce1c
* Add tid parameter to IAudioFlinger::openRecordGlenn Kasten2012-07-121-0/+4
| | | | | | Not yet implemented Change-Id: I35523fb15ad71727ecc9f4bb870f07e4b7397dc4
* Simplify AudioRecord::getInputFramesLost()Glenn Kasten2012-07-121-4/+2
| | | | | | This also fixes a benign race in reading mActive without a lock. Change-Id: I19e953d4f275e5c266ca1ca3fece7b6c02ad1707
* Use audio_channel_mask_t more consistentlyGlenn Kasten2012-07-031-4/+5
| | | | | | | | | | | | | | | In IAudioFlinger::createTrack() and IAudioFlinger::openRecord(), declare input parameter to use correct type audio_channel_mask_t. In IAudioFlinger::getInputBufferSize(), input parameter is now channel mask instead of channel count. Remove unused IAudioFlinger::channelCount(audio_io_handle_t). In AudioRecord::getMinFrameCount() and AudioSystem::getInputBufferSize(), input parameter is channel mask instead of channel count. Change-Id: Ib2f1c29bea70f016b3cfce83942ba292190ac965
* Remove acoustics from AudioSystem::getInput()Glenn Kasten2012-06-251-2/+0
| | | | Change-Id: I29fb3ee5664c1f0ee0409c1bb2be087ecca637db
* Use audio_channel_mask_t in AudioRecordGlenn Kasten2012-06-251-4/+4
| | | | Change-Id: I9e1b918b2635d961604a4a9d88eb1c7179a167a7
* Include what you useGlenn Kasten2012-06-251-17/+7
| | | | Change-Id: I12ef9367d05dbe069c037b1b4acd6347a8cf3ece
* Remove AudioRecord record_flagsGlenn Kasten2012-06-221-6/+3
| | | | Change-Id: I021ddcc1bcb63132a4597d13e3d09db2a5f2c628
* Fix issues with synchronous record start.Eric Laurent2012-05-141-1/+4
| | | | | | | | | | | | | | | | - Added a timeout in case the trigger event is never fired. - Extend AudioRecord obtainBuffer() timeout in case of synchronous start to avoid spurious warning. - Make sure that the event is triggered if the track is destroyed. - Reject event if the triggering track is in an incompatible state. Also fix a problem when restoring a static AudioTrack after a mediaserver crash. Bug 6449468. Change-Id: Ib36e11111fb88f73caa31dcb0622792737d57a4b
* Use C APIs instead of C++ APIs for policyGlenn Kasten2012-04-231-4/+4
| | | | | | | | | The C++ APIs are going away. Note: we use tid == 0 which is not supported yet by the C APIs, do not submit this until that is added. Change-Id: I0e90789e6c81c69f2544e899c52421ea5d1342be
* Configure policy of mediaserver threadsGlenn Kasten2012-04-221-4/+4
| | | | Change-Id: Ifd825590ba36996064a458f64453a94b84722cb0
* Make AudioTrack/AudioRecord handle more than 2^32 framesMarco Nelissen2012-03-301-1/+1
| | | | | b/6160363 Change-Id: I471815012c6a113ec2c4dd7676e8fa288a70bc76
* implemented synchronous audio captureEric Laurent2012-03-291-5/+7
| | | | | | | | | | | | | | Added the infrastructure to support the synchronization of playback and capture actions on specific events. The first requirement for this feature is to synchronize the audio capture start with the full rendering of a given audio content. The applications can further be extended to other use cases (synchronized playback start...) by adding new synchronization events and new synchronous control methods on player or recorders. Also added a method to query the audio session from a ToneGenerator. Change-Id: I51f1167290d9cafdf2fbcdf9e4785156973af44c
* IAudioFlinger::createTrack and openRecord flagsGlenn Kasten2012-03-191-4/+3
| | | | | | | | | | | | | | | | | | | | createTrack and openRecord don't need the "old" flags parameter, which was either audio_policy_output_t or audio_in_acoustics_t shifted left by 16 bits. But they do need "new" flags, which are defined by the application use case. Initially, the only application use case flag is timed output, but others are planned. For output, the audio_policy_output_t flags are passed to AudioSystem::getOutput, which returns an audio_io_handle_t, and that handle is then passed to createTrack. So createTrack doesn't need the old flags parameter. For input, the audio_in_acoustics_t flags are passed to AudioSystem::getInput, which returns an audio_io_handle_t, and that handle is then passed to openRecord. So openRecord doesn't need the old flags parameter. Change-Id: I18a9870911846cca69d420c19fe6a9face2fe8c4
* Whitespace and indentationGlenn Kasten2012-03-131-9/+8
| | | | | | | | | | | | | | 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
* Use AudioRecord::record_flags consistentlyGlenn Kasten2012-03-081-2/+2
| | | | Change-Id: I6f369a2b99eb515603bc7d5629a07db2b96783fe
* Merge "Shorten thread names"Glenn Kasten2012-02-291-1/+1
|\
| * Shorten thread namesGlenn Kasten2012-02-281-1/+1
| | | | | | | | | | | | | | | | 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
* | AudioRecord const methodsGlenn Kasten2012-02-281-7/+7
|/ | | | Change-Id: Ifae4fd7820b650aaca2b13c8658c292db1c46c0f
* AudioRecord and AudioTrack client tidGlenn Kasten2012-02-141-4/+33
| | | | | | Inform AudioFlinger of the tid of the callback thread. Change-Id: I670df92dd06749b057238b48ed1094b13aab720b
* Merge "Remove dead mutex in AudioTrack/AudioRecord thread"Glenn Kasten2012-02-081-13/+0
|\
| * Remove dead mutex in AudioTrack/AudioRecord threadGlenn Kasten2012-02-021-13/+0
| | | | | | | | | | | | | | | | | | | | The client callback threads had mutexes called AudioTrackThread::mLock and ClientRecordThread::mLock. These mutexes were only used by start() and stop(), and were unused by the thread itself. But start() and stop() already have their own protection provided by AudioTrack::mLock and AudioRecord::mLock. So the thread mutexes can be removed. Change-Id: I098406d381645d77fba06a15511e179a327848ef
* | Use NULL not 0 for raw pointersGlenn Kasten2012-02-031-6/+6
|/ | | | | | Use if (p != NULL) instead of if (ptr) Change-Id: Iaec3413a59ccbf233c98fcd918cc7d70ac5da9fa
* Use audio_source_t consistentlyGlenn Kasten2012-01-261-5/+5
| | | | | | | | | | | | | | | | Was a mix of audio_source_t, uint8_t, and int. Related fixes: - fix comments in MediaRecorder.java - AudioPolicyService server side was not checking source parameter at all, so if the client wrapper was bypassed, invalid values could be passed into audio HAL - JNI android_media_AudioRecord_setup was checking source for positive values, but not negative values. This test is redundant, since already checked at Java and now checked by AudioPolicyService also, but might as well make it correct. Change-Id: Ie5e25d646dcd59a86d7985aa46cfcb4a1ba64a4a
* Use audio_format_t consistently, continuedGlenn Kasten2012-01-201-6/+6
| | | | | | | | | | | | Was int or uint32_t. When AudioFlinger::format can't determine the correct format, return INVALID rather than DEFAULT. Init mFormat to INVALID rather than DEFAULT in the constructor. Subclass constructors will set mFormat to the correct value. Change-Id: I9b62640aa107d24d2d27925f5563d0d7407d1b73
* Use size_t for frame sizeGlenn Kasten2012-01-131-1/+1
| | | | | | | | | except in the control block, where we don't have room. In AudioFlinger::ThreadBase::TrackBase::getBuffer, read the frame size from control block only once. Change-Id: Id6c4bccd4ed3e07d91df6bbea43bae45524f9f4e
* libmedia new can't fail on AndroidGlenn Kasten2012-01-111-3/+0
| | | | Change-Id: Ie79dd5abb8078b35474bf0f1b3a6ff994a3a3360
* Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGESteve Block2012-01-081-9/+9
| | | | | | | See https://android-git.corp.google.com/g/#/c/157220 Bug: 5449033 Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
* Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGESteve Block2012-01-061-6/+6
| | | | | | | See https://android-git.corp.google.com/g/157065 Bug: 5449033 Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
* Use the standard CC_LIKELY and CC_UNLIKELY macrosGlenn Kasten2012-01-051-6/+4
| | | | | | | | | | | Several source files privately defined macros LIKELY and UNLIKELY in terms of __builtin_expect. But <cutils/compiler.h> already has CC_LIKELY and CC_UNLIKELY which are intended for this purpose. So rename the private uses to use the standard names. In addition, AudioFlinger was relying on the macro expanding to extra ( ). Change-Id: I2494e087a0c0cac0ac998335f5e9c8ad02955873
* Bug 4903178 Restore priority and cgroup on stopGlenn Kasten2011-11-161-5/+10
| | | | | | | | | | On AudioTrack and AudioRecord stop or failed start, restore the priority and cgroup of the caller to their previous values, rather than forcing to NORMAL. Dependent on new thread APIs. Also fixes bug where priority was set to AUDIO but cgroup not set. Change-Id: Ib83893918fb4fdf57c6b87884b51038997a631d8
* Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGESteve Block2011-10-261-7/+7
| | | | | | | See https://android-git.corp.google.com/g/#/c/143865 Bug: 5449033 Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
* Keep effects sessions active when the caller dies.Marco Nelissen2011-08-091-0/+3
| | | | | | | | Don't remove effects until the session they are in goes away or all AudioEffects have been explicitly released. This allows the control panel process to die without stopping the effects. Change-Id: I4496e5df080230ca1af149dec95c1309ab8ea888