summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
Commit message (Collapse)AuthorAgeFilesLines
* AudioRecord: use audio attributes instead of audio source.Eric Laurent2014-11-251-8/+21
| | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* audio policy: pass session ID to capture activity methodsEric Laurent2014-07-281-1/+1
| | | | | | | | Indicate the audio session ID when calling getInput(), startInput(), stopInput(), releaseInput(). Bug: 12378680. Change-Id: I763793752f93e2f4e1445a5ab217c895af011038
* rename AudioSystem::newAudioSessionId()Eric Laurent2014-07-281-1/+1
| | | | | | | | | Rename AudioSystem::newAudioSessionId() to AudioSystem::newAudioUniqueId() as it can be used also for I/O handles. Bug: 12378680. Change-Id: I611ea3b5eb57a4b0774437f477ee87dc4ccc2cc2
* Move AudioRecord frame count calculations to serverGlenn Kasten2014-07-171-44/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Buffer frame count and notification frame count are now calculated by server instead of by client. The server has more information and can do a better job. Also fix a few bugs: - If a fast track was re-created, even with same pipe depth, it would fail. Now it can correctly re-create a fast track provided the pipe depth is same. - Notification frame count for fast tracks was calculated by client as 1/2 of the total frame count, which is a large value due to the pipe. Now the notification frame count is set by server to the HAL frame count. This should reduce latency for fast tracks. - EVENT_OVERRUN were happening frequently when there was sample rate conversion, because the client didn't know about the sample rate conversion, and under-estimated the necessary buffer size. Now since server calculates the buffer sizes, EVENT_OVERRUN is unlikely. - RecordThread::createRecordTrack_l was checking for mono and stereo for fast tracks. This is not necessary, and now we can handle a multi-channel fast track. Bug: 7498763 Change-Id: I0c581618e8db33084d5ff9ed50a592990c9749e8
* Add audio_input_flags_t to IAudioPolicyService::getInputGlenn Kasten2014-07-171-3/+3
| | | | Change-Id: I9f37be05f8dc7b85a8827a94e76ca0f45453e170
* IAudioFlinger::openRecord now suggests notificationFramesGlenn Kasten2014-07-031-0/+5
| | | | Change-Id: I08885cc381d03c522a23289e74f0e1ed46563863
* libmedia: 64-bit compile warningsMark Salyzyn2014-06-201-10/+12
| | | | Change-Id: I600f062fa7148c01851023c1240c39939e648002
* 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
* Squashed commit of the following:Glenn Kasten2014-06-051-18/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 9128d6ffec43731d723f9b394f243d940f4c7e41 Author: Glenn Kasten <gkasten@google.com> Date: Tue May 13 10:38:42 2014 -0700 Use of fast capture by normal capture Will only configure fast capture path if the input buffer size is less than 10 ms and the input sample rate is same as the primary output sample rate. Change-Id: I4a7cdc6069d750845412c626d27e83f72a1ab397 commit 2e5e0806a5abe7499848358ef5fde5c26405000d Author: Glenn Kasten <gkasten@google.com> Date: Mon Jun 2 08:29:22 2014 -0700 Add mPrimaryOutputSampleRate Change-Id: I46b527fc3f2b5a5720a74b4f0b9a8f2e0d570b09 commit baf1d73467923996d1b1f2a9237260cc5697e050 Author: Andy Hung <hunga@google.com> Date: Fri May 30 10:42:03 2014 -0700 Change parameter type for volume to float in AudioMixer Change-Id: I4da1505ce852505f86f8e5b87f60e8edceeb30e0 commit 40fe20fa9760cd03c69778c2021cf7a490d75ece Author: Andy Hung <hunga@google.com> Date: Fri May 30 10:35:47 2014 -0700 Rename UNITY_GAIN to UNITY_GAIN_INT in AudioMixer Change-Id: Ic040311305026f0b4c4280a5b3bef7a447ac1da3 commit 37c9a2b49f876abc5ff537a9ec036d7f0a423775 Author: Andy Hung <hunga@google.com> Date: Thu May 29 21:33:13 2014 -0700 Refactor setVolumeRampVariables in AudioMixer Change-Id: I8fcf3101bcea292de7c65433fa578f1c9cdd0974 commit 397070eca31f121d5d3993de1bfea99aaea5d4f3 Author: Andy Hung <hunga@google.com> Date: Thu May 29 18:52:38 2014 -0700 Fix floating point output from mixer A buffer pointer was being erroneously reset to buffer start, potentially causing an audio glitch. The floating point output mode is not enabled at this time, but will be in the future. Change-Id: If8b6414d232f064f3a2e2c5a6da889a91b27fb24 commit 2e61aa5b33b2247bbc5d4eaa0b519df9accd4bbc Author: Andy Hung <hunga@google.com> Date: Fri May 23 21:22:17 2014 -0700 Add multiple format capability to FastMixer Floating point data from MixerThread into FastMixer. Multiple output format capability from FastMixer to Sink. Change-Id: I0da17810ee71381a39a006c46faec71108d22c26 commit b9ea653c702a785bbd23a66c5e588d40b4192c4e Author: Andy Hung <hunga@google.com> Date: Thu May 29 15:53:09 2014 -0700 Avoid resetting BufferProviders in mixer unnecessarily Change-Id: Iad85c4dfd21be1dbf89dc11906106b34219376f8 commit 7f1a6d6da21c616f80cf9ba21bea11b419ec561b Author: Andy Hung <hunga@google.com> Date: Tue May 27 12:32:17 2014 -0700 Update dynamic resampler buffer fetching Make the criteria tight for fetching to avoid storing excessive frame data internal to the resampler. This should reduce jitter in frame delivery computation. Bug: 14962343 Change-Id: I7adaf714d11c272696ccdbf218bda994c7217477 commit b5e4aac07b9a02f0c803c090058602b03ac09ebb Author: Glenn Kasten <gkasten@google.com> Date: Tue May 27 12:30:54 2014 -0700 Allow kFastTrackMultiplier to be specified per device Change-Id: I4eaaaf038df720cec4f5d9221d1b632970f9e3dd commit b93cd97a52af31122df2da2cc0415cda888c8c73 Author: Andy Hung <hunga@google.com> Date: Fri May 23 21:13:31 2014 -0700 Rename mixBuffer to mMixerBuffer in FastMixer Likewise mixBufferState becomes mMixerBufferState. This harmonizes with the naming in AF::MixerThread. Change-Id: I1255d7c07cc2c6ee925d7430925236d2bd163122 commit 8340758622b9711365a8801806cbdf934803c63f Author: Andy Hung <hunga@google.com> Date: Mon May 12 16:51:41 2014 -0700 Add multiple format capability to AudioMixer Change-Id: I04ac1cafd90b6ed652f8d51888ad07576678f0bc Signed-off-by: Andy Hung <hunga@google.com> commit 6b695b9d094820c232a897a3fabbe83d2b7193fe Author: Glenn Kasten <gkasten@google.com> Date: Thu Mar 13 14:59:31 2014 -0700 Start adding FastCapture based on FastThread WIP This version supports at most one fast capture client. Change-Id: Idf609bfc80ae22433433d66a5232c043c65506df commit e951ad05a2c388471d7e2806d91e7d51325a150a Author: Glenn Kasten <gkasten@google.com> Date: Mon May 12 11:06:26 2014 -0700 Move validation of frameCount from set to openRecord_l This move is needed because frameCount is validated on server side for fast tracks (as should be done for normal tracks too). Change-Id: I6d99e80869fd90fab373cf60ef348c01f075fbca commit 73e76992dbba794894837c38e5472312ea829cf3 Author: Glenn Kasten <gkasten@google.com> Date: Tue May 13 10:41:52 2014 -0700 Allow track buffer "allocation" to be from pipe Change-Id: Ib9ac170f8e8b7746b3588157a56cbee3b753a1cb commit 60de1d7ded05c6304037d4858b401094b1d2b4d3 Author: Andy Hung <hunga@google.com> Date: Fri May 9 15:02:21 2014 -0700 Add format parameter to getTrackName() and track_t Change-Id: Ia152a839014e235fbfb656104c15d7c1b456d02e Signed-off-by: Andy Hung <hunga@google.com> Change-Id: Ied0ade8b25d23e89bb03319a7e3135c238f735b9
* Use new channel count functions for audio masksAndy Hung2014-05-161-2/+3
| | | | | Change-Id: Ia658ab4b6320d19fdb50f123c930918724ff0ef3 Signed-off-by: Andy Hung <hunga@google.com>
* IAudioFlinger::openRecord returns IMemory(s)Glenn Kasten2014-05-091-8/+24
| | | | | | | | openRecord() now explicitly returns the control block and data buffer as separate IMemory references. If the IMemory for data buffer is 0, this means it immediately follows the control block. Change-Id: Ic098f88f0e037f8fbe30006689e18cacacf09d06
* Fix a couple of fast capture typo bugsGlenn Kasten2014-05-071-2/+2
| | | | | | | AudioRecord constructor was not passing flags through to set(). Server-side check was using wrong kind of channel mask. Change-Id: Ifaa880ec323771e9fd168262be05f3e539f53390
* Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>Glenn Kasten2014-03-261-1/+1
| | | | Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
* Make openRecord_l more like createTrack_l for fast tracks: part 3Glenn Kasten2014-02-281-7/+12
| | | | | | | | | Create the callback thread earlier, before creating the IAudioRecord, so that the thread's tid is available as a parameter to openRecord(). Also move initialization of mCbf to same point as in AudioTrack.cpp. Change-Id: I61ea4c5e2724ccfc691aaf51bc02a7c10d5a7495
* Make openRecord_l more like createTrack_l for fast tracks: part 2Glenn Kasten2014-02-281-10/+11
| | | | | | | | Assume double-buffering because we don't know the true HAL sample rate, and for fast tracks we must accomodate kernel scheduling and app computation jitter. Change-Id: I983d6048a8b4814cfa5bf789397cdd9f1572256c
* Merge "Make openRecord_l more like createTrack_l for fast tracks: part 1"Glenn Kasten2014-02-281-9/+21
|\
| * Make openRecord_l more like createTrack_l for fast tracks: part 1Glenn Kasten2014-02-271-9/+21
| | | | | | | | | | | | | | | | | | | | Use the transfer mode to distinguish use cases, as the presence of a callback handler is not sufficient. For example, the track could be configured for synchronous transfer with write() or read(), and also have a callback handler for position updates. But that does not mean the track can operate in fast track mode. Change-Id: I2a7f1f0ca98e68efe180b524496985109d8ce291
* | Fix type of AudioTrack/AudioRecord parameter frameCountGlenn Kasten2014-02-281-11/+4
| | | | | | | | | | | | It's size_t consistently Change-Id: I29638ef59ac773218025f2403a3508a307b487e0
* | Fix type of AudioTrack/AudioRecord parameter notificationFramesGlenn Kasten2014-02-281-4/+4
|/ | | | | | It's uint32_t consistently Change-Id: If8298c7e9aeea2b951fe47b675adbdf48d104846
* Simplify error handling after track creationGlenn Kasten2014-02-251-1/+3
| | | | | | | IAudioFlinger::createTrack and IAudioFlinger::openRecord both guarantee that (status == OK) == (sp<> != 0). Change-Id: I91cb4f7e843019efb65cace7ba146f7da7aa5b59
* Move initialize of mInput to match AudioTrackGlenn Kasten2014-02-251-3/+3
| | | | Change-Id: I4dc977f22f51cd618dc83d800b4b8756929a4612
* Update comments to match AudioTrackGlenn Kasten2014-02-251-1/+3
| | | | Change-Id: I7dd14eabd78c9130a157da2063a1d65ec4f9c65a
* Move initialization of mRefreshRemaining to match AudioTrackGlenn Kasten2014-02-251-1/+2
| | | | | | | This also fixes a bug where, for a re-created IAudioRecord, mRefreshRemaining was not being reset correctly. Change-Id: I9f721a4edf92aab859cf3f247ab7f65562d14fb0
* Merge "mAudioRecord is always non-0 if set() is successful"Glenn Kasten2014-02-251-4/+4
|\
| * mAudioRecord is always non-0 if set() is successfulGlenn Kasten2014-02-241-4/+4
| | | | | | | | Change-Id: I0c2483210903c922f06f097ada373a37b9a90a02
* | Merge "Unify comments and whitespace between AudioTrack and AudioRecord"Glenn Kasten2014-02-251-1/+2
|\ \ | |/
| * Unify comments and whitespace between AudioTrack and AudioRecordGlenn Kasten2014-02-241-1/+2
| | | | | | | | Change-Id: I5320a6b2d7f7077cb12d7da4f2ca30a940100bf2
* | Merge "Update mReqFrameCount at same point in AudioTrack and AudioRecord"Glenn Kasten2014-02-251-5/+5
|\ \ | |/
| * Update mReqFrameCount at same point in AudioTrack and AudioRecordGlenn Kasten2014-02-241-5/+5
| | | | | | | | Change-Id: I12369dfbb9e75389f2cab015a706decdaf310a0d
* | Merge "Permit AudioRecord to support non-linear formats in future"Glenn Kasten2014-02-251-2/+5
|\ \ | |/
| * Permit AudioRecord to support non-linear formats in futureGlenn Kasten2014-02-241-2/+5
| | | | | | | | | | | | But still restricted to 16-bit PCM currently Change-Id: I5df0e5033da9144ca73e44addf14a63d31406034
* | Merge "Simplify and cleanup error handling in AudioRecord::getMinFrameCount"Glenn Kasten2014-02-251-17/+10
|\ \ | |/ |/|
| * Simplify and cleanup error handling in AudioRecord::getMinFrameCountGlenn Kasten2014-02-251-17/+10
| | | | | | | | Change-Id: I8721ecedfb429c4e233453d1e768ddf69ecabbe4
* | Add log at entry to set() in AudioTrack and AudioRecordGlenn Kasten2014-02-241-3/+5
|/ | | | Change-Id: Ife23b88474c1d62c0cf682c1a310d951f2c0f54a
* Multi-client recordingGlenn Kasten2014-02-181-1/+3
| | | | | | Supports multiple clients both at native sample rate and with resampling. Change-Id: Icea55b4fd30751761b7debaa3ce016c79e712d8d
* Track pid for each sessionMarco Nelissen2014-02-111-2/+2
| | | | | | so they can be properly freed. Change-Id: I6f389035bc29e74e7c367c1c6d0252b180f666b3
* Use printf format %#x for audio_format_t in logsGlenn Kasten2014-02-071-3/+3
| | | | Change-Id: I1c611d1037685d52ccc84efe0fccd6413ec938e9
* Add AudioRecord::mReqFrameCount similar to AudioTrackGlenn Kasten2014-02-051-7/+16
| | | | Change-Id: I62d6534a9581e84ae20c2422f7ad9aeda9b7c4df
* Fix unused parameter warnings in audioGlenn Kasten2014-02-031-1/+1
| | | | Change-Id: I665ba3358dd9502f0adec70d486e7bf8a2e1b0fe
* AudioTrack: fix obtainBuffer timeout calculationEric Laurent2014-01-271-1/+1
| | | | | | | | | | | AudioTrack::obtainBuffer() passes a pointer to a timeout variable that has gone out of scope when calling ClientProxy::obtainBuffer(). Same fix for AudioRecord. Bug: 11968591. Change-Id: I22af8f94fa2f8cc54ab5c25c89167c805e754317
* Refactor code related to I/O handles to reduce chance for leaksGlenn Kasten2014-01-241-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | The AudioRecord input handle code was refactored earlier to fix a potential handle leak, and to simplify the code: > Change-Id: I124dce344b1d11c2dd66ca5e2c9aec0c52c230e2 This changelist refactors AudioTrack similarly, and adds further cleanup of both AudioTrack and AudioRecord. We attempt to implement the rules for referencing counting I/O handles, but there is still the possibility of a handle leak if the client process dies after allocating the handle reference but before releasing it. That issue is being tracked separately. Details: - AudioSystem::getOutput() is now called within createTrack_l - restoreTrack_l was missing offload info now it has the info available, but is not yet being called for offloaded tracks - AudioTrack::getOutput() is now const - Remove getOutput_l() Change-Id: I44a0a623d24fc5847bcac0939c276400568adbca
* Merge "Replace control block frameCount_ by explicit in/out parameter"Glenn Kasten2014-01-241-4/+9
|\
| * Replace control block frameCount_ by explicit in/out parameterGlenn Kasten2013-12-201-4/+9
| | | | | | | | | | | | in IAudioFlinger::createTrack and IAudioFlinger::openRecord Change-Id: I09c644c80e92c8e744b1b99055988a2588b2a83d
* | Merge "Use uint32_t sequence numbers for IAudioRecord"Glenn Kasten2014-01-171-1/+1
|\ \
| * | Use uint32_t sequence numbers for IAudioRecordGlenn Kasten2014-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it the same as for IAudioTrack. Previously we had a mix of int, int32_t and uint32_t, which could cause comparisons to fail. Change-Id: Ic72ef650ee81f65db11e42ed16d818fdf3e310f4
* | | Merge "Cleanup loop termination logic in AudioRecord::obtainBuffer()"Glenn Kasten2014-01-171-0/+3
|\ \ \
| * | | Cleanup loop termination logic in AudioRecord::obtainBuffer()Glenn Kasten2014-01-161-0/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the same change to AudioRecord, that was already done for AudioTrack in this CL: > Change-Id: I0fc48117946364cb255afd653195498891f622bd If the proxy->obtainBuffer at the end of the "do" loop fails with status DEAD_OBJECT, and the restoreRecord_l during the next trip of the "do" loop also fails, then the value of the buffer fields will be based on the previous proxy->obtainBuffer that returned DEAD_OBJECT. This will have cleared the buffer, but it's tricky. So instead explicitly clear the buffer after restoreRecord_l, before breaking out of the loop. Change-Id: Ifc97f2ab7b8195d6b149502bb5d765d2983b07be
* | | Merge "AudioRecord: fix unwanted overrun when restarting"Glenn Kasten2014-01-171-0/+3
|\ \ \
| * | | AudioRecord: fix unwanted overrun when restartingGlenn Kasten2014-01-161-0/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the same fix to AudioRecord as this CL did for AudioTrack: > Change-Id: Id703f8dc092a6f07c905eee194054b4a978f979d Details: When restarting an AudioRecord from stopped state, it is necessary to force refresh of mRemainingFrames by processAudioBuffer() as the last read before stop() could be partial. No doing so will lead into unnecessary sleep before filling the non contiguous part of the buffer returned by obtainBuffer() when processAudioBuffer() is executed for the first time after start(). Change-Id: I0ff04648e990e97bad5ea3db5be0c4151250d5e1