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

Commit fe55cba9 authored by Deyao Ren's avatar Deyao Ren Committed by Gerrit Code Review
Browse files

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

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


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


cc_library_headers {
cc_library_headers {
@@ -254,3 +253,22 @@ cc_library_headers {
    vendor_available: true,
    vendor_available: true,
    host_supported: 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 Original line Diff line number Diff line
@@ -24,6 +24,10 @@


#include "effectFactory-impl/EffectConfig.h"
#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::AudioSource;
using aidl::android::media::audio::common::AudioStreamType;
using aidl::android::media::audio::common::AudioStreamType;
using aidl::android::media::audio::common::AudioUuid;
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) {
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) {
    for (auto* libraryDirectory : kEffectLibPath) {
        std::string candidatePath = std::string(libraryDirectory) + '/' + path;
        std::string candidatePath = std::string(libraryDirectory) + '/' + path;
        if (access(candidatePath.c_str(), R_OK) == 0) {
        if (access(candidatePath.c_str(), R_OK) == 0) {
+25 −1
Original line number Original line Diff line number Diff line
@@ -21,15 +21,39 @@
#include <android/binder_process.h>
#include <android/binder_process.h>
#include <system/audio_config.h>
#include <system/audio_config.h>


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

/** Default name of effect configuration file. */
/** Default name of effect configuration file. */
static const char* kDefaultConfigName = "audio_effects_config.xml";
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() {
int main() {
    // This is a debug implementation, always enable debug logging.
    // This is a debug implementation, always enable debug logging.
    android::base::SetMinimumLogSeverity(::android::base::DEBUG);
    android::base::SetMinimumLogSeverity(::android::base::DEBUG);
    ABinderProcess_setThreadPoolMaxThreadCount(0);
    ABinderProcess_setThreadPoolMaxThreadCount(0);


    auto configFile = android::audio_find_readable_configuration_file(kDefaultConfigName);
    auto configFile = config_file_path();
    if (configFile == "") {
    if (configFile == "") {
        LOG(ERROR) << __func__ << ": config file " << kDefaultConfigName << " not found!";
        LOG(ERROR) << __func__ << ": config file " << kDefaultConfigName << " not found!";
        return EXIT_FAILURE;
        return EXIT_FAILURE;
+1 −1
Original line number Original line Diff line number Diff line
@@ -34,6 +34,6 @@ cc_library_shared {
    ],
    ],
    relative_install_path: "soundfx",
    relative_install_path: "soundfx",
    visibility: [
    visibility: [
        "//hardware/interfaces/audio/aidl/default",
        "//hardware/interfaces/audio/aidl/default:__subpackages__",
    ],
    ],
}
}
+0 −11
Original line number Original line 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