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

Commit 9e79c705 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Remove USE_LEGACY_LOCAL_AUDIO_HAL from libaudiohal

Bug: 64425558
Test: mmma frameworks/av/media/libaudiohal
Change-Id: I16fff7142e66fcf16fa5d07abcea9c8100539928
parent fa1288be
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -17,23 +17,6 @@ LOCAL_SRC_FILES := \

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    \
@@ -60,8 +43,6 @@ LOCAL_SHARED_LIBRARIES += \
    libmedia_helper  \
    libmediautils

endif  # USE_LEGACY_LOCAL_AUDIO_HAL

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+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
+0 −83
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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 "EffectHalLocal"
//#define LOG_NDEBUG 0

#include <media/EffectsFactoryApi.h>
#include <utils/Log.h>

#include "EffectHalLocal.h"

namespace android {

EffectHalLocal::EffectHalLocal(effect_handle_t handle)
        : mHandle(handle) {
}

EffectHalLocal::~EffectHalLocal() {
    int status = EffectRelease(mHandle);
    ALOGW_IF(status, "Error releasing effect %p: %s", mHandle, strerror(-status));
    mHandle = 0;
}

status_t EffectHalLocal::setInBuffer(const sp<EffectBufferHalInterface>& buffer) {
    mInBuffer = buffer;
    return OK;
}

status_t EffectHalLocal::setOutBuffer(const sp<EffectBufferHalInterface>& buffer) {
    mOutBuffer = buffer;
    return OK;
}

status_t EffectHalLocal::process() {
    if (mInBuffer == nullptr || mOutBuffer == nullptr) {
        ALOGE_IF(mInBuffer == nullptr, "Input buffer not set");
        ALOGE_IF(mOutBuffer == nullptr, "Output buffer not set");
        return NO_INIT;
    }
    return (*mHandle)->process(mHandle, mInBuffer->audioBuffer(), mOutBuffer->audioBuffer());
}

status_t EffectHalLocal::processReverse() {
    if ((*mHandle)->process_reverse != NULL) {
        if (mInBuffer == nullptr || mOutBuffer == nullptr) {
            ALOGE_IF(mInBuffer == nullptr, "Input buffer not set");
            ALOGE_IF(mOutBuffer == nullptr, "Output buffer not set");
            return NO_INIT;
        }
        return (*mHandle)->process_reverse(
                mHandle, mInBuffer->audioBuffer(), mOutBuffer->audioBuffer());
    } else {
        return INVALID_OPERATION;
    }
}

status_t EffectHalLocal::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData,
        uint32_t *replySize, void *pReplyData) {
    return (*mHandle)->command(mHandle, cmdCode, cmdSize, pCmdData, replySize, pReplyData);
}

status_t EffectHalLocal::getDescriptor(effect_descriptor_t *pDescriptor) {
    return (*mHandle)->get_descriptor(mHandle, pDescriptor);
}

status_t EffectHalLocal::close() {
    return OK;
}

} // namespace android
Loading