summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-08-06 17:32:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-06 17:32:41 +0000
commit230c5bde2779c618b26edc73443280b2d9371c70 (patch)
tree313a1848799a279e3a56859f0d474a459a981d5a /media/libmedia/AudioRecord.cpp
parent33f3177c08d238285b296d137e527ec99e34228f (diff)
parent7cd9cf70e36ad4b8eb12e24f9adbbe6fd69edebd (diff)
downloadframeworks_av-230c5bde2779c618b26edc73443280b2d9371c70.zip
frameworks_av-230c5bde2779c618b26edc73443280b2d9371c70.tar.gz
frameworks_av-230c5bde2779c618b26edc73443280b2d9371c70.tar.bz2
Merge "AudioRecord notification frames"
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r--media/libmedia/AudioRecord.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index b9a3b76..2718420 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -267,7 +267,8 @@ status_t AudioRecord::set(
mActive = false;
mCbf = cbf;
- mNotificationFrames = notificationFrames;
+ mNotificationFramesReq = notificationFrames;
+ mNotificationFramesAct = 0;
mRefreshRemaining = true;
mUserData = user;
// TODO: add audio hardware input latency here
@@ -455,7 +456,8 @@ status_t AudioRecord::openRecord_l(
if ((mTransfer != TRANSFER_CALLBACK) || (mAudioRecordThread == 0)) {
ALOGW("AUDIO_INPUT_FLAG_FAST denied by client");
// once denied, do not request again if IAudioRecord is re-created
- mFlags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_FAST);
+ flags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_FAST);
+ mFlags = flags;
} else {
trackFlags |= IAudioFlinger::TRACK_FAST;
tid = mAudioRecordThread->getTid();
@@ -491,6 +493,27 @@ status_t AudioRecord::openRecord_l(
mCblkMemory = iMem;
audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMem->pointer());
mCblk = cblk;
+ // FIXME missing fast track frameCount logic
+ mAwaitBoost = false;
+ mNotificationFramesAct = mNotificationFramesReq;
+ if (flags & AUDIO_INPUT_FLAG_FAST) {
+ if (trackFlags & IAudioFlinger::TRACK_FAST) {
+ ALOGV("AUDIO_INPUT_FLAG_FAST successful; frameCount %u", frameCount);
+ mAwaitBoost = true;
+ // double-buffering is not required for fast tracks, due to tighter scheduling
+ if (mNotificationFramesAct == 0 || mNotificationFramesAct > frameCount) {
+ mNotificationFramesAct = frameCount;
+ }
+ } else {
+ ALOGV("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %u", frameCount);
+ // once denied, do not request again if IAudioRecord is re-created
+ flags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_FAST);
+ mFlags = flags;
+ if (mNotificationFramesAct == 0 || mNotificationFramesAct > frameCount/2) {
+ mNotificationFramesAct = frameCount/2;
+ }
+ }
+ }
// starting address of buffers in shared memory
void *buffers = (char*)cblk + sizeof(audio_track_cblk_t);
@@ -498,7 +521,7 @@ status_t AudioRecord::openRecord_l(
// update proxy
mProxy = new AudioRecordClientProxy(cblk, buffers, frameCount, mFrameSize);
mProxy->setEpoch(epoch);
- mProxy->setMinimum(mNotificationFrames);
+ mProxy->setMinimum(mNotificationFramesAct);
mDeathNotifier = new DeathNotifier(this);
mAudioRecord->asBinder()->linkToDeath(mDeathNotifier, this);
@@ -745,7 +768,7 @@ nsecs_t AudioRecord::processAudioBuffer(const sp<AudioRecordThread>& thread)
}
// Cache other fields that will be needed soon
- size_t notificationFrames = mNotificationFrames;
+ size_t notificationFrames = mNotificationFramesAct;
if (mRefreshRemaining) {
mRefreshRemaining = false;
mRemainingFrames = notificationFrames;