Skip to content

Commit 8463b73

Browse files
committed
Improve log header and fix some includes
1 parent 5840621 commit 8463b73

34 files changed

Lines changed: 247 additions & 193 deletions

CMakeLists.txt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
cmake_minimum_required(VERSION 3.16.3)
2-
set(CMAKE_CXX_COMPILER_VERSION 20)
32

4-
# NDK Settings
5-
#add_compile_definitions(ANDROID_ABI=arm64-v8a)
6-
#add_compile_definitions(ANDROID_ABI=armeabi-v7a)
7-
#add_compile_definitions(ANDROID_ARM_NEON=true)
8-
#add_compile_definitions(ANDROID_PLATFORM=android-24)
3+
set(CMAKE_CXX_STANDARD 20)
94

105
project("ViPER4Android")
116
add_compile_definitions(VIPER_VERSION=20240314)
127

13-
# FFTS
14-
#add_subdirectory(src/viper/ffts)
15-
168
# ViPERFX
179
include_directories(src/include)
1810

@@ -70,16 +62,9 @@ set(FILES
7062
src/viper/utils/TimeConstDelay.cpp
7163
src/viper/utils/WaveBuffer.cpp)
7264

73-
add_library(
74-
# Sets the name of the library.
75-
v4a_re
76-
77-
# Sets the library as a shared library.
78-
SHARED
79-
80-
# Provides a relative path to your source file(s).
65+
add_library(v4a_re SHARED
8166
${FILES})
8267

83-
target_link_libraries(v4a_re log) # kissfft)
68+
target_link_libraries(v4a_re log)
8469
target_compile_options(v4a_re PRIVATE -flto -O3 -DNDEBUG)
8570
#target_compile_options(v4afx_r PRIVATE -O2 -DNDEBUG -Wall -Wsign-conversion -Wno-unused-result -Wno-unneeded-internal-declaration -fstrict-aliasing -fvisibility=hidden -Wextra -Wno-unused-parameter)

src/ViPER4Aidl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <media/AidlConversionNdk.h>
2727
#include <system/audio_effects/effect_uuid.h>
2828

29-
#include "viper/constants.h"
29+
#include <constants.h>
3030
#include "ViPER4Aidl.h"
3131

3232
using aidl::android::hardware::audio::effect::Descriptor;

src/ViPER4Android.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#ifdef AOSP_SOONG_BUILD
44
#include <hardware/audio_effect.h>
55
#else
6-
#include "essential.h"
6+
#include <essential.h>
77
#endif
88

99
#include "viper/ViPER.h"
10-
#include "viper/constants.h"
10+
#include <constants.h>
1111
#include "ViperContext.h"
1212

1313
extern "C" {

src/ViperContext.cpp

Lines changed: 123 additions & 124 deletions
Large diffs are not rendered by default.

src/ViperContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifdef AOSP_SOONG_BUILD
66
#include <system/audio_effect.h>
77
#else
8-
#include "essential.h"
8+
#include <essential.h>
99
#endif
1010
#include "viper/ViPER.h"
1111
#include <string>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <cerrno>
77
#endif
88

9-
#include "../log.h" // TODO: Remove this dependency
9+
#include <log.h> // TODO: Remove this dependency
1010

1111
enum class Architecture : uint8_t {
1212
UNKNOWN = 0,

src/include/log.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright 2013 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+
#pragma once
18+
19+
#include <android/log.h>
20+
21+
#ifndef LOG_TAG
22+
#define LOG_TAG "ViPER4Android"
23+
#endif
24+
25+
#ifndef LOG_NDEBUG
26+
#ifdef NDEBUG
27+
#define LOG_NDEBUG 1
28+
#else
29+
#define LOG_NDEBUG 0
30+
#endif
31+
#endif
32+
33+
34+
/*
35+
* Basic log message macros intended to emulate the behavior of log/log.h
36+
* in system core. This should be dependent only on ndk exposed logging
37+
* functionality.
38+
*/
39+
40+
#ifndef ALOG
41+
#define ALOG(priority, tag, ...) \
42+
__android_log_print(ANDROID_##priority, tag, __VA_ARGS__)
43+
#endif
44+
45+
#ifndef ALOGV
46+
#if LOG_NDEBUG
47+
#define ALOGV(...) ((void)0)
48+
#else
49+
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
50+
#endif
51+
#endif
52+
53+
#ifndef ALOGD
54+
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
55+
#endif
56+
57+
#ifndef ALOGI
58+
#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
59+
#endif
60+
61+
#ifndef ALOGW
62+
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
63+
#endif
64+
65+
#ifndef ALOGE
66+
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
67+
#endif
68+
69+
#ifndef ALOGF
70+
#define ALOGF(...) ((void)ALOG(LOG_FATAL, LOG_TAG, __VA_ARGS__))
71+
#endif
72+
73+
/*
74+
* Log a fatal error if cond is true. The condition test is inverted from
75+
* assert(3) semantics. The test and message are not stripped from release
76+
* builds
77+
*/
78+
#ifndef ALOG_ALWAYS_FATAL_IF
79+
#define ALOG_ALWAYS_FATAL_IF(cond, ...) \
80+
if (cond) __android_log_assert(#cond, LOG_TAG, __VA_ARGS__)
81+
#endif

src/log.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/viper/ViPER.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "ViPER.h"
22
#include <cstring>
3-
#include <chrono>
4-
#include "constants.h"
3+
#include <constants.h>
4+
#include <log.h>
55

66
ViPER::ViPER() :
77
frameCount(0),
@@ -11,8 +11,8 @@ ViPER::ViPER() :
1111
iirFilter(IIRFilter(10)),
1212
gainL(1.0),
1313
gainR(1.0) {
14-
VIPER_LOGI("Welcome to ViPER FX");
15-
VIPER_LOGI("Current version is %d", VIPER_VERSION);
14+
ALOGI("Welcome to ViPER FX");
15+
ALOGI("Current version is %d", VIPER_VERSION);
1616

1717
this->convolver.SetEnable(false);
1818
this->convolver.SetSamplingRate(this->samplingRate);
@@ -94,7 +94,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
9494
uint32_t tmpBufSize;
9595

9696
if (this->convolver.GetEnabled() || this->vhe.GetEnabled()) {
97-
// VIPER_LOGD("Convolver or VHE is enable, use wave buffer");
97+
// ALOGD("Convolver or VHE is enable, use wave buffer");
9898

9999
if (!this->waveBuffer.PushSamples(buffer.data(), size)) {
100100
this->waveBuffer.Reset();
@@ -119,7 +119,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
119119
tmpBuf = ptr;
120120
tmpBufSize = ret;
121121
} else {
122-
// VIPER_LOGD("Convolver and VHE are disabled, use adaptive buffer");
122+
// ALOGD("Convolver and VHE are disabled, use adaptive buffer");
123123

124124
if (this->adaptiveBuffer.PushFrames(buffer.data(), size)) {
125125
this->adaptiveBuffer.SetBufferOffset(size);
@@ -132,7 +132,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
132132
}
133133
}
134134

135-
// VIPER_LOGD("Process buffer size: %d", tmpBufSize);
135+
// ALOGD("Process buffer size: %d", tmpBufSize);
136136
if (tmpBufSize != 0) {
137137
this->viperDdc.Process(tmpBuf, size);
138138
this->spectrumExtend.Process(tmpBuf, size);
@@ -175,7 +175,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
175175

176176
//void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize,
177177
// signed char *arr) {
178-
// VIPER_LOGD("Dispatch command: %d, %d, %d, %d, %d, %d, %p", param, val1, val2, val3, val4, arrSize, arr);
178+
// ALOGD("Dispatch command: %d, %d, %d, %d, %d, %d, %p", param, val1, val2, val3, val4, arrSize, arr);
179179
// switch (param) {
180180
// case PARAM_SET_RESET_STATUS: {
181181
// this->reset();

src/viper/effects/AnalogX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AnalogX.h"
22
#include <cstring>
3-
#include "../constants.h"
3+
#include <constants.h>
44

55
static const float ANALOGX_HARMONICS[] = {
66
0.01f,

0 commit comments

Comments
 (0)