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

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

Merge changes I4244d085,I16fff714

* changes:
  Convert libaudiohal to Android.bp
  Remove USE_LEGACY_LOCAL_AUDIO_HAL from libaudiohal
parents c297fb28 f33e4b85
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "libaudiohal",

    srcs: [
        "DeviceHalLocal.cpp",
        "DevicesFactoryHalHybrid.cpp",
        "DevicesFactoryHalLocal.cpp",
        "StreamHalLocal.cpp",

        "ConversionHelperHidl.cpp",
        "HalDeathHandlerHidl.cpp",
        "DeviceHalHidl.cpp",
        "DevicesFactoryHalHidl.cpp",
        "EffectBufferHalHidl.cpp",
        "EffectHalHidl.cpp",
        "EffectsFactoryHalHidl.cpp",
        "StreamHalHidl.cpp",
    ],

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

    shared_libs: [
        "libaudioutils",
        "libcutils",
        "liblog",
        "libutils",
        "libhardware",
        "libbase",
        "libfmq",
        "libhwbinder",
        "libhidlbase",
        "libhidlmemory",
        "libhidltransport",
        "android.hardware.audio@2.0",
        "android.hardware.audio.common@2.0",
        "android.hardware.audio.common@2.0-util",
        "android.hardware.audio.effect@2.0",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "libmedia_helper",
        "libmediautils",
    ],
}

media/libaudiohal/Android.mk

deleted100644 → 0
+0 −71
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SHARED_LIBRARIES := \
    libaudioutils \
    libcutils   \
    liblog      \
    libutils    \
    libhardware

LOCAL_SRC_FILES := \
    DeviceHalLocal.cpp          \
    DevicesFactoryHalHybrid.cpp \
    DevicesFactoryHalLocal.cpp  \
    StreamHalLocal.cpp

LOCAL_CFLAGS := -Wall -Werror

ifeq ($(USE_LEGACY_LOCAL_AUDIO_HAL), true)

# Use audiohal directly w/o hwbinder middleware.
# This is for performance comparison and debugging only.

LOCAL_SRC_FILES += \
    EffectBufferHalLocal.cpp    \
    EffectsFactoryHalLocal.cpp  \
    EffectHalLocal.cpp

LOCAL_SHARED_LIBRARIES += \
    libeffects

LOCAL_CFLAGS += -DUSE_LEGACY_LOCAL_AUDIO_HAL

else  # if !USE_LEGACY_LOCAL_AUDIO_HAL

LOCAL_SRC_FILES += \
    ConversionHelperHidl.cpp   \
    HalDeathHandlerHidl.cpp    \
    DeviceHalHidl.cpp          \
    DevicesFactoryHalHidl.cpp  \
    EffectBufferHalHidl.cpp    \
    EffectHalHidl.cpp          \
    EffectsFactoryHalHidl.cpp  \
    StreamHalHidl.cpp

LOCAL_SHARED_LIBRARIES += \
    libbase          \
    libfmq           \
    libhwbinder      \
    libhidlbase      \
    libhidlmemory    \
    libhidltransport \
    android.hardware.audio@2.0             \
    android.hardware.audio.common@2.0      \
    android.hardware.audio.common@2.0-util \
    android.hardware.audio.effect@2.0      \
    android.hidl.allocator@1.0             \
    android.hidl.memory@1.0                \
    libmedia_helper  \
    libmediautils

endif  # USE_LEGACY_LOCAL_AUDIO_HAL

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include

LOCAL_MODULE := libaudiohal

include $(BUILD_SHARED_LIBRARY)
+1 −9
Original line number Diff line number Diff line
@@ -19,9 +19,7 @@

#include "DevicesFactoryHalHybrid.h"
#include "DevicesFactoryHalLocal.h"
#ifndef USE_LEGACY_LOCAL_AUDIO_HAL
#include "DevicesFactoryHalHidl.h"
#endif

namespace android {

@@ -32,13 +30,7 @@ sp<DevicesFactoryHalInterface> DevicesFactoryHalInterface::create() {

DevicesFactoryHalHybrid::DevicesFactoryHalHybrid()
        : mLocalFactory(new DevicesFactoryHalLocal()),
          mHidlFactory(
#ifdef USE_LEGACY_LOCAL_AUDIO_HAL
                  nullptr
#else
                  new DevicesFactoryHalHidl()
#endif
                       ) {
          mHidlFactory(new DevicesFactoryHalHidl()) {
}

DevicesFactoryHalHybrid::~DevicesFactoryHalHybrid() {
+0 −91
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "EffectBufferHalLocal"
//#define LOG_NDEBUG 0

#include <utils/Log.h>

#include "EffectBufferHalLocal.h"

namespace android {

// static
status_t EffectBufferHalInterface::allocate(
        size_t size, sp<EffectBufferHalInterface>* buffer) {
    *buffer = new EffectBufferHalLocal(size);
    return OK;
}

// static
status_t EffectBufferHalInterface::mirror(
        void* external, size_t size, sp<EffectBufferHalInterface>* buffer) {
    *buffer = new EffectBufferHalLocal(external, size);
    return OK;
}

EffectBufferHalLocal::EffectBufferHalLocal(size_t size)
        : mOwnBuffer(new uint8_t[size]),
          mBufferSize(size), mFrameCountChanged(false),
          mAudioBuffer{0, {mOwnBuffer.get()}} {
}

EffectBufferHalLocal::EffectBufferHalLocal(void* external, size_t size)
        : mOwnBuffer(nullptr),
          mBufferSize(size), mFrameCountChanged(false),
          mAudioBuffer{0, {external}} {
}

EffectBufferHalLocal::~EffectBufferHalLocal() {
}

audio_buffer_t* EffectBufferHalLocal::audioBuffer() {
    return &mAudioBuffer;
}

void* EffectBufferHalLocal::externalData() const {
    return mAudioBuffer.raw;
}

void EffectBufferHalLocal::setFrameCount(size_t frameCount) {
    mAudioBuffer.frameCount = frameCount;
    mFrameCountChanged = true;
}

void EffectBufferHalLocal::setExternalData(void* external) {
    ALOGE_IF(mOwnBuffer != nullptr, "Attempt to set external data for allocated buffer");
    mAudioBuffer.raw = external;
}

bool EffectBufferHalLocal::checkFrameCountChange() {
    bool result = mFrameCountChanged;
    mFrameCountChanged = false;
    return result;
}

void EffectBufferHalLocal::update() {
}

void EffectBufferHalLocal::commit() {
}

void EffectBufferHalLocal::update(size_t) {
}

void EffectBufferHalLocal::commit(size_t) {
}

} // namespace android
+0 −61
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_HARDWARE_EFFECT_BUFFER_HAL_LOCAL_H
#define ANDROID_HARDWARE_EFFECT_BUFFER_HAL_LOCAL_H

#include <memory>

#include <media/audiohal/EffectBufferHalInterface.h>
#include <system/audio_effect.h>

namespace android {

class EffectBufferHalLocal : public EffectBufferHalInterface
{
  public:
    virtual audio_buffer_t* audioBuffer();
    virtual void* externalData() const;

    virtual void setExternalData(void* external);
    virtual void setFrameCount(size_t frameCount);
    virtual bool checkFrameCountChange();

    virtual void update();
    virtual void commit();
    virtual void update(size_t size);
    virtual void commit(size_t size);

  private:
    friend class EffectBufferHalInterface;

    std::unique_ptr<uint8_t[]> mOwnBuffer;
    const size_t mBufferSize;
    bool mFrameCountChanged;
    audio_buffer_t mAudioBuffer;

    // Can not be constructed directly by clients.
    explicit EffectBufferHalLocal(size_t size);
    EffectBufferHalLocal(void* external, size_t size);

    virtual ~EffectBufferHalLocal();

    status_t init();
};

} // namespace android

#endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_LOCAL_H
Loading