1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "EffectBufferHalLocal"
18//#define LOG_NDEBUG 0
19
20#include <utils/Log.h>
21
22#include "EffectBufferHalLocal.h"
23
24namespace android {
25
26// static
27status_t EffectBufferHalInterface::allocate(
28        size_t size, sp<EffectBufferHalInterface>* buffer) {
29    *buffer = new EffectBufferHalLocal(size);
30    return OK;
31}
32
33// static
34status_t EffectBufferHalInterface::mirror(
35        void* external, size_t size, sp<EffectBufferHalInterface>* buffer) {
36    *buffer = new EffectBufferHalLocal(external, size);
37    return OK;
38}
39
40EffectBufferHalLocal::EffectBufferHalLocal(size_t size)
41        : mOwnBuffer(new uint8_t[size]),
42          mBufferSize(size), mFrameCountChanged(false),
43          mAudioBuffer{0, {mOwnBuffer.get()}} {
44}
45
46EffectBufferHalLocal::EffectBufferHalLocal(void* external, size_t size)
47        : mOwnBuffer(nullptr),
48          mBufferSize(size), mFrameCountChanged(false),
49          mAudioBuffer{0, {external}} {
50}
51
52EffectBufferHalLocal::~EffectBufferHalLocal() {
53}
54
55audio_buffer_t* EffectBufferHalLocal::audioBuffer() {
56    return &mAudioBuffer;
57}
58
59void* EffectBufferHalLocal::externalData() const {
60    return mAudioBuffer.raw;
61}
62
63void EffectBufferHalLocal::setFrameCount(size_t frameCount) {
64    mAudioBuffer.frameCount = frameCount;
65    mFrameCountChanged = true;
66}
67
68void EffectBufferHalLocal::setExternalData(void* external) {
69    ALOGE_IF(mOwnBuffer != nullptr, "Attempt to set external data for allocated buffer");
70    mAudioBuffer.raw = external;
71}
72
73bool EffectBufferHalLocal::checkFrameCountChange() {
74    bool result = mFrameCountChanged;
75    mFrameCountChanged = false;
76    return result;
77}
78
79void EffectBufferHalLocal::update() {
80}
81
82void EffectBufferHalLocal::commit() {
83}
84
85void EffectBufferHalLocal::update(size_t) {
86}
87
88void EffectBufferHalLocal::commit(size_t) {
89}
90
91} // namespace android
92