summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-11-26 23:56:44 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-26 23:56:44 +0000
commit390ef84373b7edd1397381f780ca235326357094 (patch)
treeb939b5391c9de74956f4829dfba71ef4a36aa3fa /media/libmedia/AudioRecord.cpp
parent9574c274bf03900b56628b0c923d40f03cb30562 (diff)
parentf20c4356931ef72084b6b8e310f56b67715c6fb9 (diff)
downloadframeworks_av-390ef84373b7edd1397381f780ca235326357094.zip
frameworks_av-390ef84373b7edd1397381f780ca235326357094.tar.gz
frameworks_av-390ef84373b7edd1397381f780ca235326357094.tar.bz2
am f20c4356: Merge "AudioRecord: use audio attributes instead of audio source." into lmp-mr1-dev
* commit 'f20c4356931ef72084b6b8e310f56b67715c6fb9': AudioRecord: use audio attributes instead of audio source.
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r--media/libmedia/AudioRecord.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 77437d1..d9646d9 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -82,14 +82,16 @@ AudioRecord::AudioRecord(
uint32_t notificationFrames,
int sessionId,
transfer_type transferType,
- audio_input_flags_t flags)
+ audio_input_flags_t flags,
+ const audio_attributes_t* pAttributes)
: mStatus(NO_INIT), mSessionId(AUDIO_SESSION_ALLOCATE),
mPreviousPriority(ANDROID_PRIORITY_NORMAL),
mPreviousSchedulingGroup(SP_DEFAULT),
mProxy(NULL)
{
mStatus = set(inputSource, sampleRate, format, channelMask, frameCount, cbf, user,
- notificationFrames, false /*threadCanCallJava*/, sessionId, transferType, flags);
+ notificationFrames, false /*threadCanCallJava*/, sessionId, transferType, flags,
+ pAttributes);
}
AudioRecord::~AudioRecord()
@@ -126,7 +128,8 @@ status_t AudioRecord::set(
bool threadCanCallJava,
int sessionId,
transfer_type transferType,
- audio_input_flags_t flags)
+ audio_input_flags_t flags,
+ const audio_attributes_t* pAttributes)
{
ALOGV("set(): inputSource %d, sampleRate %u, format %#x, channelMask %#x, frameCount %zu, "
"notificationFrames %u, sessionId %d, transferType %d, flags %#x",
@@ -168,7 +171,15 @@ status_t AudioRecord::set(
if (inputSource == AUDIO_SOURCE_DEFAULT) {
inputSource = AUDIO_SOURCE_MIC;
}
- mInputSource = inputSource;
+ if (pAttributes == NULL) {
+ memset(&mAttributes, 0, sizeof(audio_attributes_t));
+ mAttributes.source = inputSource;
+ } else {
+ // stream type shouldn't be looked at, this track has audio attributes
+ memcpy(&mAttributes, pAttributes, sizeof(audio_attributes_t));
+ ALOGV("Building AudioRecord with attributes: source=%d flags=0x%x tags=[%s]",
+ mAttributes.source, mAttributes.flags, mAttributes.tags);
+ }
if (sampleRate == 0) {
ALOGE("Invalid sample rate %u", sampleRate);
@@ -444,12 +455,14 @@ status_t AudioRecord::openRecord_l(size_t epoch)
}
}
- audio_io_handle_t input = AudioSystem::getInput(mInputSource, mSampleRate, mFormat,
- mChannelMask, (audio_session_t)mSessionId, mFlags);
- if (input == AUDIO_IO_HANDLE_NONE) {
+ audio_io_handle_t input;
+ status = AudioSystem::getInputForAttr(&mAttributes, &input, (audio_session_t)mSessionId,
+ mSampleRate, mFormat, mChannelMask, mFlags);
+
+ if (status != NO_ERROR) {
ALOGE("Could not get audio input for record source %d, sample rate %u, format %#x, "
"channel mask %#x, session %d, flags %#x",
- mInputSource, mSampleRate, mFormat, mChannelMask, mSessionId, mFlags);
+ mAttributes.source, mSampleRate, mFormat, mChannelMask, mSessionId, mFlags);
return BAD_VALUE;
}
{