Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e724f2bc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 18bef531 89e82232
Loading
Loading
Loading
Loading
+9 −29
Original line number Diff line number Diff line
@@ -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;
}