diff options
author | Eric Laurent <elaurent@google.com> | 2014-11-27 00:06:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-27 00:06:00 +0000 |
commit | 61280541836947ce0b281b240ffa4c55bbf5bd55 (patch) | |
tree | 4a287a2b07095295e7f054399fd9fb3052629d70 /media/libmedia/AudioRecord.cpp | |
parent | b438123fb1ee0a8c232fd66de658d5382d2083cf (diff) | |
parent | 390ef84373b7edd1397381f780ca235326357094 (diff) | |
download | frameworks_av-61280541836947ce0b281b240ffa4c55bbf5bd55.zip frameworks_av-61280541836947ce0b281b240ffa4c55bbf5bd55.tar.gz frameworks_av-61280541836947ce0b281b240ffa4c55bbf5bd55.tar.bz2 |
am 390ef843: am f20c4356: Merge "AudioRecord: use audio attributes instead of audio source." into lmp-mr1-dev
* commit '390ef84373b7edd1397381f780ca235326357094':
AudioRecord: use audio attributes instead of audio source.
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r-- | media/libmedia/AudioRecord.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 5b5fe5d..8ad6c8b 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; } { |