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

Commit 66f0387a authored by Deyao Ren's avatar Deyao Ren Committed by Automerger Merge Worker
Browse files

Merge "Create vendor apex for cuttlefish audio and audio effect" into main am: fe55cba9

parents 54f12450 fe55cba9
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -115,8 +115,6 @@ cc_library {
cc_binary {
    name: "android.hardware.audio.service-aidl.example",
    relative_install_path: "hw",
    init_rc: ["android.hardware.audio.service-aidl.example.rc"],
    vintf_fragments: ["android.hardware.audio.service-aidl.xml"],
    defaults: [
        "aidlaudioservice_defaults",
        "latest_android_hardware_audio_core_sounddose_ndk_shared",
@@ -142,6 +140,7 @@ cc_binary {
        "-Wthread-safety",
        "-DBACKEND_NDK",
    ],
    installable: false, //installed in apex com.android.hardware.audio
}

cc_test {
@@ -235,10 +234,9 @@ filegroup {
cc_binary {
    name: "android.hardware.audio.effect.service-aidl.example",
    relative_install_path: "hw",
    init_rc: ["android.hardware.audio.effect.service-aidl.example.rc"],
    vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
    defaults: ["aidlaudioeffectservice_defaults"],
    shared_libs: [
        "libapexsupport",
        "libtinyxml2",
    ],
    srcs: [
@@ -246,6 +244,7 @@ cc_binary {
        "EffectFactory.cpp",
        "EffectMain.cpp",
    ],
    installable: false, //installed in apex com.android.hardware.audio.effect
}

cc_library_headers {
@@ -254,3 +253,22 @@ cc_library_headers {
    vendor_available: true,
    host_supported: true,
}

prebuilt_etc {
    name: "android.hardware.audio.service-aidl.example.rc",
    src: "android.hardware.audio.service-aidl.example.rc",
    installable: false,
}

prebuilt_etc {
    name: "android.hardware.audio.service-aidl.xml",
    src: "android.hardware.audio.service-aidl.xml",
    sub_dir: "vintf",
    installable: false,
}

prebuilt_etc {
    name: "audio_effects_config.xml",
    src: "audio_effects_config.xml",
    installable: false,
}
+22 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@

#include "effectFactory-impl/EffectConfig.h"

#ifdef __ANDROID_APEX__
#include <android/apexsupport.h>
#endif

using aidl::android::media::audio::common::AudioSource;
using aidl::android::media::audio::common::AudioStreamType;
using aidl::android::media::audio::common::AudioUuid;
@@ -89,6 +93,24 @@ std::vector<std::reference_wrapper<const tinyxml2::XMLElement>> EffectConfig::ge
}

bool EffectConfig::resolveLibrary(const std::string& path, std::string* resolvedPath) {
    if (__builtin_available(android AAPEXSUPPORT_API, *)) {
        AApexInfo *apexInfo;
        if (AApexInfo_create(&apexInfo) == AAPEXINFO_OK) {
            std::string apexName(AApexInfo_getName(apexInfo));
            AApexInfo_destroy(apexInfo);
            std::string candidatePath("/apex/");
            candidatePath.append(apexName).append(kEffectLibApexPath).append(path);
            LOG(DEBUG) << __func__ << " effect lib path " << candidatePath;
            if (access(candidatePath.c_str(), R_OK) == 0) {
                *resolvedPath = std::move(candidatePath);
                return true;
            }
        }
    } else {
        LOG(DEBUG) << __func__ << " libapexsupport is not supported";
    }

    // If audio effects libs are not in vendor apex, locate them in kEffectLibPath
    for (auto* libraryDirectory : kEffectLibPath) {
        std::string candidatePath = std::string(libraryDirectory) + '/' + path;
        if (access(candidatePath.c_str(), R_OK) == 0) {
+25 −1
Original line number Diff line number Diff line
@@ -21,15 +21,39 @@
#include <android/binder_process.h>
#include <system/audio_config.h>

#ifdef __ANDROID_APEX__
#include <android/apexsupport.h>
#endif

/** Default name of effect configuration file. */
static const char* kDefaultConfigName = "audio_effects_config.xml";

static inline std::string config_file_path() {
    if (__builtin_available(android AAPEXSUPPORT_API, *)) {
        AApexInfo *apexInfo;
        if (AApexInfo_create(&apexInfo) == AAPEXINFO_OK) {
            std::string apexName(AApexInfo_getName(apexInfo));
            AApexInfo_destroy(apexInfo);
            std::string candidatePath("/apex/");
            candidatePath.append(apexName).append("/etc/").append(kDefaultConfigName);
            LOG(DEBUG) << __func__ << " effect lib path " << candidatePath;
            if (access(candidatePath.c_str(), R_OK) == 0) {
                return std::move(candidatePath);
            }
        }
    } else {
        LOG(DEBUG) << __func__ << " libapexsupport is not supported";
    }
    LOG(DEBUG) << __func__ << ": Unable to resolve config file path in APEX";
    return android::audio_find_readable_configuration_file(kDefaultConfigName);
}

int main() {
    // This is a debug implementation, always enable debug logging.
    android::base::SetMinimumLogSeverity(::android::base::DEBUG);
    ABinderProcess_setThreadPoolMaxThreadCount(0);

    auto configFile = android::audio_find_readable_configuration_file(kDefaultConfigName);
    auto configFile = config_file_path();
    if (configFile == "") {
        LOG(ERROR) << __func__ << ": config file " << kDefaultConfigName << " not found!";
        return EXIT_FAILURE;
+1 −1
Original line number Diff line number Diff line
@@ -34,6 +34,6 @@ cc_library_shared {
    ],
    relative_install_path: "soundfx",
    visibility: [
        "//hardware/interfaces/audio/aidl/default",
        "//hardware/interfaces/audio/aidl/default:__subpackages__",
    ],
}
+0 −11
Original line number Diff line number Diff line
service vendor.audio-effect-hal-aidl /vendor/bin/hw/android.hardware.audio.effect.service-aidl.example
    class hal
    user audioserver
    # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
    group audio media
    capabilities BLOCK_SUSPEND
    # setting RLIMIT_RTPRIO allows binder RT priority inheritance
    rlimit rtprio 10 10
    ioprio rt 4
    task_profiles ProcessCapacityHigh HighPerformance
    onrestart restart audioserver
Loading