Merge "Make AudioPolicyManager::getInputForDevice prefer profile match on input fast flag" into pi-dev am: 85d2e91d3c

am: 56f91c5405

Change-Id: I06e7769499febd3bd113d369332799d34ad0db2c
gugelfrei
Glenn Kasten 6 years ago committed by android-build-merger
commit 651061189c

@ -55,7 +55,9 @@ public:
audio_format_t *updatedFormat,
audio_channel_mask_t channelMask,
audio_channel_mask_t *updatedChannelMask,
uint32_t flags) const;
// FIXME parameter type
uint32_t flags,
bool exactMatchRequiredForInputFlags = false) const;
void dump(int fd);
void log();

@ -35,7 +35,9 @@ bool IOProfile::isCompatibleProfile(audio_devices_t device,
audio_format_t *updatedFormat,
audio_channel_mask_t channelMask,
audio_channel_mask_t *updatedChannelMask,
uint32_t flags) const
// FIXME type punning here
uint32_t flags,
bool exactMatchRequiredForInputFlags) const
{
const bool isPlaybackThread =
getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SOURCE;
@ -90,7 +92,7 @@ bool IOProfile::isCompatibleProfile(audio_devices_t device,
// An existing normal stream is compatible with a fast track request,
// but the fast request will be denied by AudioFlinger and converted to normal track.
if (isRecordThread && ((getFlags() ^ flags) &
~AUDIO_INPUT_FLAG_FAST)) {
~(exactMatchRequiredForInputFlags ? AUDIO_INPUT_FLAG_NONE : AUDIO_INPUT_FLAG_FAST))) {
return false;
}

@ -1602,10 +1602,11 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(audio_devices_t device,
// 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 = config->format;
audio_format_t profileFormat;
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, address,
profileSamplingRate, profileFormat, profileChannelMask,
profileFlags);
@ -5057,21 +5058,46 @@ sp<IOProfile> AudioPolicyManager::getInputProfile(audio_devices_t device,
// TODO: perhaps isCompatibleProfile should return a "matching" score so we can return
// the best matching profile, not the first one.
sp<IOProfile> firstInexact;
uint32_t updatedSamplingRate = 0;
audio_format_t updatedFormat = AUDIO_FORMAT_INVALID;
audio_channel_mask_t updatedChannelMask = AUDIO_CHANNEL_INVALID;
for (const auto& hwModule : mHwModules) {
for (const auto& profile : hwModule->getInputProfiles()) {
// profile->log();
//updatedFormat = format;
if (profile->isCompatibleProfile(device, address, samplingRate,
&samplingRate /*updatedSamplingRate*/,
&samplingRate /*updatedSamplingRate*/,
format,
&format /*updatedFormat*/,
&format, /*updatedFormat*/
channelMask,
&channelMask /*updatedChannelMask*/,
(audio_output_flags_t) flags)) {
&channelMask /*updatedChannelMask*/,
// FIXME ugly cast
(audio_output_flags_t) flags,
true /*exactMatchRequiredForInputFlags*/)) {
return profile;
}
if (firstInexact == nullptr && profile->isCompatibleProfile(device, address,
samplingRate,
&updatedSamplingRate,
format,
&updatedFormat,
channelMask,
&updatedChannelMask,
// FIXME ugly cast
(audio_output_flags_t) flags,
false /*exactMatchRequiredForInputFlags*/)) {
firstInexact = profile;
}
}
}
if (firstInexact != nullptr) {
samplingRate = updatedSamplingRate;
format = updatedFormat;
channelMask = updatedChannelMask;
return firstInexact;
}
return NULL;
}

Loading…
Cancel
Save