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

Commit 7588ff41 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio V4: Split HAL wrapper for versioning



Both core and effect Hal now have one single point of entry.
This point of entry is their respective factories:
 - DevicesFactoryHalInterface::create
 - EffectsFactoryHalInterface::create

Each entry point looks for their respective services supported
version, starting from the highest (currently only 2.0) and
returning the subclass wrapping this version to the most recent audio.h
framework api.

Note that EffectBufferHalInterface were previously created from static
methods (mirror and allocate) which broke the single point of entry
requirement.
As a result, buffers have now to be created from the factory like the
other classes.

Note that the death handler also need to be its own library as it is
used by versioned code and is version independent.

Bug: 38184704
Test: compile
Change-Id: Iac9b1fda561bb486193d5b9e025a870f50cda530
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 51ac542d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
cc_library_shared {
    name: "libaudiohal",
    name: "libaudiohal@2.0",

    srcs: [
        "DeviceHalLocal.cpp",
@@ -8,7 +8,6 @@ cc_library_shared {
        "StreamHalLocal.cpp",

        "ConversionHelperHidl.cpp",
        "HalDeathHandlerHidl.cpp",
        "DeviceHalHidl.cpp",
        "DevicesFactoryHalHidl.cpp",
        "EffectBufferHalHidl.cpp",
@@ -17,12 +16,14 @@ cc_library_shared {
        "StreamHalHidl.cpp",
    ],

    export_include_dirs: ["."],

    cflags: [
        "-Wall",
        "-Werror",
    ],

    shared_libs: [
        "libaudiohal_deathhandler",
        "libaudioutils",
        "libcutils",
        "liblog",
@@ -46,4 +47,8 @@ cc_library_shared {
    header_libs: [
        "libaudiohal_headers"
    ],

    export_shared_lib_headers: [
        "libfmq",
    ],
}
+0 −5
Original line number Diff line number Diff line
@@ -23,11 +23,6 @@

namespace android {

// static
sp<DevicesFactoryHalInterface> DevicesFactoryHalInterface::create() {
    return new DevicesFactoryHalHybrid();
}

DevicesFactoryHalHybrid::DevicesFactoryHalHybrid()
        : mLocalFactory(new DevicesFactoryHalLocal()),
          mHidlFactory(new DevicesFactoryHalHidl()) {
+2 −4
Original line number Diff line number Diff line
@@ -37,14 +37,12 @@ uint64_t EffectBufferHalHidl::makeUniqueId() {
    return counter++;
}

// static
status_t EffectBufferHalInterface::allocate(
status_t EffectBufferHalHidl::allocate(
        size_t size, sp<EffectBufferHalInterface>* buffer) {
    return mirror(nullptr, size, buffer);
}

// static
status_t EffectBufferHalInterface::mirror(
status_t EffectBufferHalHidl::mirror(
        void* external, size_t size, sp<EffectBufferHalInterface>* buffer) {
    sp<EffectBufferHalInterface> tempBuffer = new EffectBufferHalHidl(size);
    status_t result = static_cast<EffectBufferHalHidl*>(tempBuffer.get())->init();
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ namespace android {
class EffectBufferHalHidl : public EffectBufferHalInterface
{
  public:
    static status_t allocate(size_t size, sp<EffectBufferHalInterface>* buffer);
    static status_t mirror(void* external, size_t size, sp<EffectBufferHalInterface>* buffer);

    virtual audio_buffer_t* audioBuffer();
    virtual void* externalData() const;

+11 −10
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <cutils/native_handle.h>

#include "ConversionHelperHidl.h"
#include "EffectBufferHalHidl.h"
#include "EffectHalHidl.h"
#include "EffectsFactoryHalHidl.h"
#include "HidlUtils.h"
@@ -32,16 +33,6 @@ using ::android::hardware::Return;

namespace android {

// static
sp<EffectsFactoryHalInterface> EffectsFactoryHalInterface::create() {
    return new EffectsFactoryHalHidl();
}

// static
bool EffectsFactoryHalInterface::isNullUuid(const effect_uuid_t *pEffectUuid) {
    return memcmp(pEffectUuid, EFFECT_UUID_NULL, sizeof(effect_uuid_t)) == 0;
}

EffectsFactoryHalHidl::EffectsFactoryHalHidl() : ConversionHelperHidl("EffectsFactory") {
    mEffectsFactory = IEffectsFactory::getService();
    if (mEffectsFactory == 0) {
@@ -146,4 +137,14 @@ status_t EffectsFactoryHalHidl::dumpEffects(int fd) {
    return processReturn(__FUNCTION__, ret);
}

status_t EffectsFactoryHalHidl::allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) {
    return EffectBufferHalHidl::allocate(size, buffer);
}

status_t EffectsFactoryHalHidl::mirrorBuffer(void* external, size_t size,
                          sp<EffectBufferHalInterface>* buffer) {
    return EffectBufferHalHidl::mirror(external, size, buffer);
}


} // namespace android
Loading