Merge "audiopolicy: Get Hw offloaded A2DP formats from declared devices"

gugelfrei
TreeHugger Robot 5 years ago committed by Android (Google) Code Review
commit e724f2bcb3

@ -479,36 +479,16 @@ status_t AudioPolicyManager::getHwOffloadEncodingFormatsSupportedForA2DP(
std::vector<audio_format_t> *formats)
{
ALOGV("getHwOffloadEncodingFormatsSupportedForA2DP()");
char *tok = NULL, *saveptr;
status_t status = NO_ERROR;
char encoding_formats_list[PROPERTY_VALUE_MAX];
audio_format_t format = AUDIO_FORMAT_DEFAULT;
// FIXME This list should not come from a property but the supported encoded
// formats of declared A2DP devices in primary module
property_get("persist.bluetooth.a2dp_offload.cap", encoding_formats_list, "");
tok = strtok_r(encoding_formats_list, "-", &saveptr);
for (;tok != NULL; tok = strtok_r(NULL, "-", &saveptr)) {
if (strcmp(tok, "sbc") == 0) {
ALOGV("%s: SBC offload supported\n",__func__);
format = AUDIO_FORMAT_SBC;
} else if (strcmp(tok, "aptx") == 0) {
ALOGV("%s: APTX offload supported\n",__func__);
format = AUDIO_FORMAT_APTX;
} else if (strcmp(tok, "aptxhd") == 0) {
ALOGV("%s: APTX HD offload supported\n",__func__);
format = AUDIO_FORMAT_APTX_HD;
} else if (strcmp(tok, "ldac") == 0) {
ALOGV("%s: LDAC offload supported\n",__func__);
format = AUDIO_FORMAT_LDAC;
} else if (strcmp(tok, "aac") == 0) {
ALOGV("%s: AAC offload supported\n",__func__);
format = AUDIO_FORMAT_AAC;
} else {
ALOGE("%s: undefined token - %s\n",__func__, tok);
continue;
}
formats->push_back(format);
}
std::unordered_set<audio_format_t> formatSet;
sp<HwModule> primaryModule =
mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_PRIMARY);
DeviceVector declaredDevices = primaryModule->getDeclaredDevices().getDevicesFromTypeMask(
AUDIO_DEVICE_OUT_ALL_A2DP);
for (const auto& device : declaredDevices) {
formatSet.insert(device->encodedFormats().begin(), device->encodedFormats().end());
}
formats->assign(formatSet.begin(), formatSet.end());
return status;
}

Loading…
Cancel
Save