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 /services/audiopolicy | |
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 'services/audiopolicy')
-rw-r--r-- | services/audiopolicy/AudioPolicyInterface.h | 13 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyInterfaceImpl.cpp | 45 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp | 38 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 71 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.h | 13 | ||||
-rw-r--r-- | services/audiopolicy/AudioPolicyService.h | 13 |
6 files changed, 99 insertions, 94 deletions
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h index f7ffb6d..5bcbca8 100644 --- a/services/audiopolicy/AudioPolicyInterface.h +++ b/services/audiopolicy/AudioPolicyInterface.h @@ -113,12 +113,13 @@ public: audio_session_t session) = 0; // request an input appropriate for record from the supplied device with supplied parameters. - virtual audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t session, - audio_input_flags_t flags) = 0; + virtual status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags) = 0; // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input, audio_session_t session) = 0; diff --git a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp index 8b64d5b..abb1b21 100644 --- a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp +++ b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp @@ -243,47 +243,48 @@ void AudioPolicyService::doReleaseOutput(audio_io_handle_t output, mAudioPolicyManager->releaseOutput(output, stream, session); } -audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t audioSession, - audio_input_flags_t flags) +status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags) { if (mAudioPolicyManager == NULL) { - return 0; + return NO_INIT; } // already checked by client, but double-check in case the client wrapper is bypassed - if (inputSource >= AUDIO_SOURCE_CNT && inputSource != AUDIO_SOURCE_HOTWORD && - inputSource != AUDIO_SOURCE_FM_TUNER) { - return 0; + if (attr->source >= AUDIO_SOURCE_CNT && attr->source != AUDIO_SOURCE_HOTWORD && + attr->source != AUDIO_SOURCE_FM_TUNER) { + return BAD_VALUE; } - if (((inputSource == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || - ((inputSource == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { - return 0; + if (((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || + ((attr->source == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { + return BAD_VALUE; } - audio_io_handle_t input; sp<AudioPolicyEffects>audioPolicyEffects; + status_t status; { Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() - input = mAudioPolicyManager->getInput(inputSource, samplingRate, - format, channelMask, - audioSession, flags); + status = mAudioPolicyManager->getInputForAttr(attr, input, session, + samplingRate, format, channelMask, + flags); audioPolicyEffects = mAudioPolicyEffects; } - if (input == 0) { - return input; + if (status != NO_ERROR) { + return status; } if (audioPolicyEffects != 0) { // create audio pre processors according to input source - status_t status = audioPolicyEffects->addInputEffects(input, inputSource, audioSession); + status_t status = audioPolicyEffects->addInputEffects(*input, attr->source, session); if (status != NO_ERROR && status != ALREADY_EXISTS) { - ALOGW("Failed to add effects on input %d", input); + ALOGW("Failed to add effects on input %d", *input); } } - return input; + return NO_ERROR; } status_t AudioPolicyService::startInput(audio_io_handle_t input, diff --git a/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp b/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp index 694dea3..4e42b25 100644 --- a/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp +++ b/services/audiopolicy/AudioPolicyInterfaceImplLegacy.cpp @@ -230,48 +230,48 @@ void AudioPolicyService::doReleaseOutput(audio_io_handle_t output, mpAudioPolicy->release_output(mpAudioPolicy, output); } -audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t audioSession, - audio_input_flags_t flags __unused) +status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags __unused) { if (mpAudioPolicy == NULL) { - return 0; + return NO_INIT; } // already checked by client, but double-check in case the client wrapper is bypassed - if (inputSource >= AUDIO_SOURCE_CNT && inputSource != AUDIO_SOURCE_HOTWORD && - inputSource != AUDIO_SOURCE_FM_TUNER) { - return 0; + if (attr->source >= AUDIO_SOURCE_CNT && attr->source != AUDIO_SOURCE_HOTWORD && + attr->source != AUDIO_SOURCE_FM_TUNER) { + return BAD_VALUE; } - if (((inputSource == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || - ((inputSource == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { - return 0; + if (((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) || + ((attr->source == AUDIO_SOURCE_FM_TUNER) && !captureFmTunerAllowed())) { + return BAD_VALUE; } - audio_io_handle_t input; sp<AudioPolicyEffects>audioPolicyEffects; { Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() - input = mpAudioPolicy->get_input(mpAudioPolicy, inputSource, samplingRate, + *input = mpAudioPolicy->get_input(mpAudioPolicy, attr->source, samplingRate, format, channelMask, (audio_in_acoustics_t) 0); audioPolicyEffects = mAudioPolicyEffects; } - if (input == 0) { - return input; + if (*input == AUDIO_IO_HANDLE_NONE) { + return INVALID_OPERATION; } if (audioPolicyEffects != 0) { // create audio pre processors according to input source - status_t status = audioPolicyEffects->addInputEffects(input, inputSource, audioSession); + status_t status = audioPolicyEffects->addInputEffects(*input, attr->source, session); if (status != NO_ERROR && status != ALREADY_EXISTS) { ALOGW("Failed to add effects on input %d", input); } } - return input; + return NO_ERROR; } status_t AudioPolicyService::startInput(audio_io_handle_t input, diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index cd8df2f..b5a3d5b 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -900,7 +900,7 @@ status_t AudioPolicyManager::getOutputForAttr(const audio_attributes_t *attr, audio_io_handle_t AudioPolicyManager::getOutputForDevice( audio_devices_t device, - audio_session_t session, + audio_session_t session __unused, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, @@ -1294,8 +1294,8 @@ status_t AudioPolicyManager::stopOutput(audio_io_handle_t output, } void AudioPolicyManager::releaseOutput(audio_io_handle_t output, - audio_stream_type_t stream, - audio_session_t session) + audio_stream_type_t stream __unused, + audio_session_t session __unused) { ALOGV("releaseOutput() %d", output); ssize_t index = mOutputs.indexOfKey(output); @@ -1338,26 +1338,27 @@ void AudioPolicyManager::releaseOutput(audio_io_handle_t output, } -audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t session, - audio_input_flags_t flags) +status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags) { - ALOGV("getInput() inputSource %d, samplingRate %d, format %d, channelMask %x, session %d, " - "flags %#x", - inputSource, samplingRate, format, channelMask, session, flags); + ALOGV("getInputForAttr() source %d, samplingRate %d, format %d, channelMask %x," + "session %d, flags %#x", + attr->source, samplingRate, format, channelMask, session, flags); - audio_devices_t device = getDeviceForInputSource(inputSource); + audio_devices_t device = getDeviceForInputSource(attr->source); if (device == AUDIO_DEVICE_NONE) { - ALOGW("getInput() could not find device for inputSource %d", inputSource); - return AUDIO_IO_HANDLE_NONE; + ALOGW("getInputForAttr() could not find device for source %d", attr->source); + return BAD_VALUE; } // adapt channel selection to input source - switch (inputSource) { + switch (attr->source) { case AUDIO_SOURCE_VOICE_UPLINK: channelMask = AUDIO_CHANNEL_IN_VOICE_UPLINK; break; @@ -1371,16 +1372,16 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, break; } - audio_io_handle_t input = AUDIO_IO_HANDLE_NONE; + *input = AUDIO_IO_HANDLE_NONE; bool isSoundTrigger = false; - audio_source_t halInputSource = inputSource; - if (inputSource == AUDIO_SOURCE_HOTWORD) { + audio_source_t halInputSource = attr->source; + if (attr->source == AUDIO_SOURCE_HOTWORD) { ssize_t index = mSoundTriggerSessions.indexOfKey(session); if (index >= 0) { - input = mSoundTriggerSessions.valueFor(session); + *input = mSoundTriggerSessions.valueFor(session); isSoundTrigger = true; flags = (audio_input_flags_t)(flags | AUDIO_INPUT_FLAG_HW_HOTWORD); - ALOGV("SoundTrigger capture on session %d input %d", session, input); + ALOGV("SoundTrigger capture on session %d input %d", session, *input); } else { halInputSource = AUDIO_SOURCE_VOICE_RECOGNITION; } @@ -1401,16 +1402,16 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, channelMask, flags); if (profile == 0) { - ALOGW("getInput() could not find profile for device 0x%X, samplingRate %u, format %#x, " - "channelMask 0x%X, flags %#x", + ALOGW("getInputForAttr() could not find profile for device 0x%X, samplingRate %u," + "format %#x, channelMask 0x%X, flags %#x", device, samplingRate, format, channelMask, log_flags); - return AUDIO_IO_HANDLE_NONE; + return BAD_VALUE; } } if (profile->mModule->mHandle == 0) { - ALOGE("getInput(): HW module %s not opened", profile->mModule->mName); - return AUDIO_IO_HANDLE_NONE; + ALOGE("getInputForAttr(): HW module %s not opened", profile->mModule->mName); + return NO_INIT; } audio_config_t config = AUDIO_CONFIG_INITIALIZER; @@ -1422,7 +1423,7 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, String8 address = deviceDistinguishesOnAddress(device) ? String8("0") : String8(""); status_t status = mpClientInterface->openInput(profile->mModule->mHandle, - &input, + input, &config, &device, address, @@ -1430,20 +1431,20 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, flags); // only accept input with the exact requested set of parameters - if (status != NO_ERROR || + if (status != NO_ERROR || *input == AUDIO_IO_HANDLE_NONE || (samplingRate != config.sample_rate) || (format != config.format) || (channelMask != config.channel_mask)) { - ALOGW("getInput() failed opening input: samplingRate %d, format %d, channelMask %x", + ALOGW("getInputForAttr() failed opening input: samplingRate %d, format %d, channelMask %x", samplingRate, format, channelMask); - if (input != AUDIO_IO_HANDLE_NONE) { - mpClientInterface->closeInput(input); + if (*input != AUDIO_IO_HANDLE_NONE) { + mpClientInterface->closeInput(*input); } - return AUDIO_IO_HANDLE_NONE; + return BAD_VALUE; } sp<AudioInputDescriptor> inputDesc = new AudioInputDescriptor(profile); - inputDesc->mInputSource = inputSource; + inputDesc->mInputSource = attr->source; inputDesc->mRefCount = 0; inputDesc->mOpenRefCount = 1; inputDesc->mSamplingRate = samplingRate; @@ -1453,9 +1454,9 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, inputDesc->mSessions.add(session); inputDesc->mIsSoundTrigger = isSoundTrigger; - addInput(input, inputDesc); + addInput(*input, inputDesc); mpClientInterface->onAudioPortListUpdate(); - return input; + return NO_ERROR; } status_t AudioPolicyManager::startInput(audio_io_handle_t input, diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h index 6eb2163..e2b6480 100644 --- a/services/audiopolicy/AudioPolicyManager.h +++ b/services/audiopolicy/AudioPolicyManager.h @@ -105,12 +105,13 @@ public: virtual void releaseOutput(audio_io_handle_t output, audio_stream_type_t stream, audio_session_t session); - virtual audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t session, - audio_input_flags_t flags); + virtual status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags); // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input, diff --git a/services/audiopolicy/AudioPolicyService.h b/services/audiopolicy/AudioPolicyService.h index 23f335e..74a59a8 100644 --- a/services/audiopolicy/AudioPolicyService.h +++ b/services/audiopolicy/AudioPolicyService.h @@ -92,12 +92,13 @@ public: virtual void releaseOutput(audio_io_handle_t output, audio_stream_type_t stream, audio_session_t session); - virtual audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_session_t audioSession, - audio_input_flags_t flags); + virtual status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags); virtual status_t startInput(audio_io_handle_t input, audio_session_t session); virtual status_t stopInput(audio_io_handle_t input, |