Merge "AudioRecord: Use original flags during track recreation" into nyc-dev
am: 633666975f
* commit '633666975ff9a85475a7d134d297eec4e1e513f8':
AudioRecord: Use original flags during track recreation
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index b0bc2d0..b034c8e 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -596,7 +596,13 @@
size_t mFrameSize; // app-level frame size == AudioFlinger frame size
uint32_t mLatency; // in ms
audio_channel_mask_t mChannelMask;
- audio_input_flags_t mFlags;
+
+ audio_input_flags_t mFlags; // same as mOrigFlags, except for bits that may
+ // be denied by client or server, such as
+ // AUDIO_INPUT_FLAG_FAST. mLock must be
+ // held to read or write those bits reliably.
+ audio_input_flags_t mOrigFlags; // as specified in constructor or set(), const
+
int mSessionId;
transfer_type mTransfer;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index fef20d9..9eb5ec7 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -246,7 +246,7 @@
mClientPid = pid;
}
- mFlags = flags;
+ mOrigFlags = mFlags = flags;
mCbf = cbf;
if (cbf != NULL) {
@@ -518,6 +518,9 @@
}
audio_io_handle_t input;
+ // mFlags (not mOrigFlags) is modified depending on whether fast request is accepted.
+ // After fast request is denied, we will request again if IAudioRecord is re-created.
+
status_t status;
status = AudioSystem::getInputForAttr(&mAttributes, &input,
(audio_session_t)mSessionId,
@@ -569,7 +572,6 @@
ALOGW("AUDIO_INPUT_FLAG_FAST denied by client; transfer %d, "
"track %u Hz, input %u Hz",
mTransfer, mSampleRate, afSampleRate);
- // once denied, do not request again if IAudioRecord is re-created
mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST);
}
}
@@ -669,8 +671,7 @@
ALOGV("AUDIO_INPUT_FLAG_FAST successful; frameCount %zu", frameCount);
mAwaitBoost = true;
} else {
- ALOGV("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
- // once denied, do not request again if IAudioRecord is re-created
+ ALOGW("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST);
}
}
@@ -1140,6 +1141,8 @@
ALOGW("dead IAudioRecord, creating a new one from %s()", from);
++mSequence;
+ mFlags = mOrigFlags;
+
// if the new IAudioRecord is created, openRecord_l() will modify the
// following member variables: mAudioRecord, mCblkMemory, mCblk, mBufferMemory.
// It will also delete the strong references on previous IAudioRecord and IMemory