Loading services/audiopolicy/managerdefault/AudioPolicyManager.cpp +65 −60 Original line number Diff line number Diff line Loading @@ -2595,31 +2595,19 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(const sp<DeviceDescripto flags = (audio_input_flags_t)(flags | AUDIO_INPUT_FLAG_ULTRASOUND); } // find a compatible input profile (not necessarily identical in parameters) sp<IOProfile> profile; // sampling rate and flags may be updated by getInputProfile uint32_t profileSamplingRate = (config->sample_rate == 0) ? SAMPLE_RATE_HZ_DEFAULT : config->sample_rate; audio_format_t profileFormat; audio_format_t profileFormat = config->format; audio_channel_mask_t profileChannelMask = config->channel_mask; audio_input_flags_t profileFlags = flags; for (;;) { profileFormat = config->format; // reset each time through loop, in case it is updated profile = getInputProfile(device, profileSamplingRate, profileFormat, profileChannelMask, profileFlags); if (profile != 0) { break; // success } else if (profileFlags & AUDIO_INPUT_FLAG_RAW) { profileFlags = (audio_input_flags_t) (profileFlags & ~AUDIO_INPUT_FLAG_RAW); // retry } else if (profileFlags != AUDIO_INPUT_FLAG_NONE && audio_is_linear_pcm(config->format)) { profileFlags = AUDIO_INPUT_FLAG_NONE; // retry } else { // fail ALOGW("%s could not find profile for device %s, sampling rate %u, format %#x, " "channel mask 0x%X, flags %#x", __func__, device->toString().c_str(), config->sample_rate, config->format, config->channel_mask, flags); // find a compatible input profile (not necessarily identical in parameters) sp<IOProfile> profile = getInputProfile( device, profileSamplingRate, profileFormat, profileChannelMask, profileFlags); if (profile == nullptr) { return input; } } // Pick input sampling rate if not specified by client uint32_t samplingRate = config->sample_rate; if (samplingRate == 0) { Loading Loading @@ -7094,11 +7082,16 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(const sp<DeviceDescriptor> &de { // Choose an input profile based on the requested capture parameters: select the first available // profile supporting all requested parameters. // The flags can be ignored if it doesn't contain a much match flag. // // TODO: perhaps isCompatibleProfile should return a "matching" score so we can return // the best matching profile, not the first one. sp<IOProfile> firstInexact; const audio_input_flags_t mustMatchFlag = AUDIO_INPUT_FLAG_MMAP_NOIRQ; const audio_input_flags_t oriFlags = flags; for (;;) { sp<IOProfile> firstInexact = nullptr; uint32_t updatedSamplingRate = 0; audio_format_t updatedFormat = AUDIO_FORMAT_INVALID; audio_channel_mask_t updatedChannelMask = AUDIO_CHANNEL_INVALID; Loading Loading @@ -7129,16 +7122,28 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(const sp<DeviceDescriptor> &de false /*exactMatchRequiredForInputFlags*/)) { firstInexact = profile; } } } if (firstInexact != nullptr) { samplingRate = updatedSamplingRate; format = updatedFormat; channelMask = updatedChannelMask; return firstInexact; } else if (flags & AUDIO_INPUT_FLAG_RAW) { flags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_RAW); // retry } else if ((flags & mustMatchFlag) == AUDIO_INPUT_FLAG_NONE && flags != AUDIO_INPUT_FLAG_NONE && audio_is_linear_pcm(format)) { flags = AUDIO_INPUT_FLAG_NONE; } else { // fail ALOGW("%s could not find profile for device %s, sampling rate %u, format %#x, " "channel mask 0x%X, flags %#x", __func__, device->toString().c_str(), samplingRate, format, channelMask, oriFlags); break; } } return NULL; return nullptr; } float AudioPolicyManager::computeVolume(IVolumeCurves &curves, Loading Loading
services/audiopolicy/managerdefault/AudioPolicyManager.cpp +65 −60 Original line number Diff line number Diff line Loading @@ -2595,31 +2595,19 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(const sp<DeviceDescripto flags = (audio_input_flags_t)(flags | AUDIO_INPUT_FLAG_ULTRASOUND); } // find a compatible input profile (not necessarily identical in parameters) sp<IOProfile> profile; // sampling rate and flags may be updated by getInputProfile uint32_t profileSamplingRate = (config->sample_rate == 0) ? SAMPLE_RATE_HZ_DEFAULT : config->sample_rate; audio_format_t profileFormat; audio_format_t profileFormat = config->format; audio_channel_mask_t profileChannelMask = config->channel_mask; audio_input_flags_t profileFlags = flags; for (;;) { profileFormat = config->format; // reset each time through loop, in case it is updated profile = getInputProfile(device, profileSamplingRate, profileFormat, profileChannelMask, profileFlags); if (profile != 0) { break; // success } else if (profileFlags & AUDIO_INPUT_FLAG_RAW) { profileFlags = (audio_input_flags_t) (profileFlags & ~AUDIO_INPUT_FLAG_RAW); // retry } else if (profileFlags != AUDIO_INPUT_FLAG_NONE && audio_is_linear_pcm(config->format)) { profileFlags = AUDIO_INPUT_FLAG_NONE; // retry } else { // fail ALOGW("%s could not find profile for device %s, sampling rate %u, format %#x, " "channel mask 0x%X, flags %#x", __func__, device->toString().c_str(), config->sample_rate, config->format, config->channel_mask, flags); // find a compatible input profile (not necessarily identical in parameters) sp<IOProfile> profile = getInputProfile( device, profileSamplingRate, profileFormat, profileChannelMask, profileFlags); if (profile == nullptr) { return input; } } // Pick input sampling rate if not specified by client uint32_t samplingRate = config->sample_rate; if (samplingRate == 0) { Loading Loading @@ -7094,11 +7082,16 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(const sp<DeviceDescriptor> &de { // Choose an input profile based on the requested capture parameters: select the first available // profile supporting all requested parameters. // The flags can be ignored if it doesn't contain a much match flag. // // TODO: perhaps isCompatibleProfile should return a "matching" score so we can return // the best matching profile, not the first one. sp<IOProfile> firstInexact; const audio_input_flags_t mustMatchFlag = AUDIO_INPUT_FLAG_MMAP_NOIRQ; const audio_input_flags_t oriFlags = flags; for (;;) { sp<IOProfile> firstInexact = nullptr; uint32_t updatedSamplingRate = 0; audio_format_t updatedFormat = AUDIO_FORMAT_INVALID; audio_channel_mask_t updatedChannelMask = AUDIO_CHANNEL_INVALID; Loading Loading @@ -7129,16 +7122,28 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(const sp<DeviceDescriptor> &de false /*exactMatchRequiredForInputFlags*/)) { firstInexact = profile; } } } if (firstInexact != nullptr) { samplingRate = updatedSamplingRate; format = updatedFormat; channelMask = updatedChannelMask; return firstInexact; } else if (flags & AUDIO_INPUT_FLAG_RAW) { flags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_RAW); // retry } else if ((flags & mustMatchFlag) == AUDIO_INPUT_FLAG_NONE && flags != AUDIO_INPUT_FLAG_NONE && audio_is_linear_pcm(format)) { flags = AUDIO_INPUT_FLAG_NONE; } else { // fail ALOGW("%s could not find profile for device %s, sampling rate %u, format %#x, " "channel mask 0x%X, flags %#x", __func__, device->toString().c_str(), samplingRate, format, channelMask, oriFlags); break; } } return NULL; return nullptr; } float AudioPolicyManager::computeVolume(IVolumeCurves &curves, Loading