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

Commit f430cf43 authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "preprocessing: Format the code using clang-format"

parents 59e92fdb b6926c79
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
../../../../../build/soong/scripts/system-clang-format
 No newline at end of file
+787 −1000

File changed.

Preview size limit exceeded, changes collapsed.

+134 −149
Original line number Diff line number Diff line
@@ -47,13 +47,13 @@
 * BM_PREPROCESSING/5/3      13254 ns        13212 ns        52972
 *******************************************************************/

#include <audio_effects/effect_aec.h>
#include <audio_effects/effect_agc.h>
#include <array>
#include <climits>
#include <cstdlib>
#include <random>
#include <vector>
#include <audio_effects/effect_aec.h>
#include <audio_effects/effect_agc.h>
#ifndef WEBRTC_LEGACY
#include <audio_effects/effect_agc2.h>
#endif
@@ -83,11 +83,8 @@ constexpr effect_uuid_t kEffectUuids[] = {
};
constexpr size_t kNumEffectUuids = std::size(kEffectUuids);
constexpr audio_channel_mask_t kChMasks[] = {
    AUDIO_CHANNEL_IN_MONO,
    AUDIO_CHANNEL_IN_STEREO,
    AUDIO_CHANNEL_IN_2POINT0POINT2,
    AUDIO_CHANNEL_IN_2POINT1POINT2,
    AUDIO_CHANNEL_IN_6,
        AUDIO_CHANNEL_IN_MONO,          AUDIO_CHANNEL_IN_STEREO, AUDIO_CHANNEL_IN_2POINT0POINT2,
        AUDIO_CHANNEL_IN_2POINT1POINT2, AUDIO_CHANNEL_IN_6,
};
constexpr size_t kNumChMasks = std::size(kChMasks);

@@ -104,8 +101,8 @@ enum PreProcId {

int preProcCreateEffect(effect_handle_t* pEffectHandle, uint32_t effectType,
                        effect_config_t* pConfig, int sessionId, int ioId) {
  if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.create_effect(
          &kEffectUuids[effectType], sessionId, ioId, pEffectHandle);
    if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.create_effect(&kEffectUuids[effectType],
                                                                 sessionId, ioId, pEffectHandle);
        status != 0) {
        ALOGE("Audio Preprocessing create returned an error = %d\n", status);
        return EXIT_FAILURE;
@@ -113,8 +110,7 @@ int preProcCreateEffect(effect_handle_t *pEffectHandle, uint32_t effectType,
    int reply = 0;
    uint32_t replySize = sizeof(reply);
    if (effectType == PREPROC_AEC) {
    if (int status =
            (**pEffectHandle)
        if (int status = (**pEffectHandle)
                                 ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG_REVERSE,
                                           sizeof(effect_config_t), pConfig, &replySize, &reply);
            status != 0) {
@@ -122,8 +118,7 @@ int preProcCreateEffect(effect_handle_t *pEffectHandle, uint32_t effectType,
            return EXIT_FAILURE;
        }
    }
  if (int status =
          (**pEffectHandle)
    if (int status = (**pEffectHandle)
                             ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG,
                                       sizeof(effect_config_t), pConfig, &replySize, &reply);
        status != 0) {
@@ -133,18 +128,16 @@ int preProcCreateEffect(effect_handle_t *pEffectHandle, uint32_t effectType,
    return reply;
}

int preProcSetConfigParam(effect_handle_t effectHandle, uint32_t paramType,
                          uint32_t paramValue) {
int preProcSetConfigParam(effect_handle_t effectHandle, uint32_t paramType, uint32_t paramValue) {
    int reply = 0;
    uint32_t replySize = sizeof(reply);
    uint32_t paramData[2] = {paramType, paramValue};
  effect_param_t *effectParam =
      (effect_param_t *)malloc(sizeof(*effectParam) + sizeof(paramData));
    effect_param_t* effectParam = (effect_param_t*)malloc(sizeof(*effectParam) + sizeof(paramData));
    memcpy(&effectParam->data[0], &paramData[0], sizeof(paramData));
    effectParam->psize = sizeof(paramData[0]);
    (*effectHandle)
      ->command(effectHandle, EFFECT_CMD_SET_PARAM, sizeof(effect_param_t),
                effectParam, &replySize, &reply);
            ->command(effectHandle, EFFECT_CMD_SET_PARAM, sizeof(effect_param_t), effectParam,
                      &replySize, &reply);
    free(effectParam);
    return reply;
}
@@ -167,8 +160,7 @@ static void BM_PREPROCESSING(benchmark::State &state) {
    config.inputCfg.channels = config.outputCfg.channels = chMask;
    config.inputCfg.format = config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;

  if (int status = preProcCreateEffect(&effectHandle, state.range(1), &config,
                                       sessionId, ioId);
    if (int status = preProcCreateEffect(&effectHandle, state.range(1), &config, sessionId, ioId);
        status != 0) {
        ALOGE("Create effect call returned error %i", status);
        return;
@@ -176,9 +168,9 @@ static void BM_PREPROCESSING(benchmark::State &state) {

    int reply = 0;
    uint32_t replySize = sizeof(reply);
  if (int status = (*effectHandle)
                       ->command(effectHandle, EFFECT_CMD_ENABLE, 0, nullptr,
                                 &replySize, &reply);
    if (int status =
                (*effectHandle)
                        ->command(effectHandle, EFFECT_CMD_ENABLE, 0, nullptr, &replySize, &reply);
        status != 0) {
        ALOGE("Command enable call returned error %d\n", reply);
        return;
@@ -204,32 +196,26 @@ static void BM_PREPROCESSING(benchmark::State &state) {
        benchmark::DoNotOptimize(out.data());
        benchmark::DoNotOptimize(farIn.data());

    audio_buffer_t inBuffer = {.frameCount = (size_t)frameLength,
                               .s16 = in.data()};
    audio_buffer_t outBuffer = {.frameCount = (size_t)frameLength,
                                .s16 = out.data()};
    audio_buffer_t farInBuffer = {.frameCount = (size_t)frameLength,
                                  .s16 = farIn.data()};
        audio_buffer_t inBuffer = {.frameCount = (size_t)frameLength, .s16 = in.data()};
        audio_buffer_t outBuffer = {.frameCount = (size_t)frameLength, .s16 = out.data()};
        audio_buffer_t farInBuffer = {.frameCount = (size_t)frameLength, .s16 = farIn.data()};

        if (PREPROC_AEC == effectType) {
      if (int status = preProcSetConfigParam(effectHandle, AEC_PARAM_ECHO_DELAY,
                                             kStreamDelayMs);
            if (int status =
                        preProcSetConfigParam(effectHandle, AEC_PARAM_ECHO_DELAY, kStreamDelayMs);
                status != 0) {
                ALOGE("preProcSetConfigParam returned Error %d\n", status);
                return;
            }
        }
    if (int status =
            (*effectHandle)->process(effectHandle, &inBuffer, &outBuffer);
        if (int status = (*effectHandle)->process(effectHandle, &inBuffer, &outBuffer);
            status != 0) {
      ALOGE("\nError: Process i = %d returned with error %d\n",
            (int)state.range(1), status);
            ALOGE("\nError: Process i = %d returned with error %d\n", (int)state.range(1), status);
            return;
        }
        if (PREPROC_AEC == effectType) {
            if (int status =
              (*effectHandle)
                  ->process_reverse(effectHandle, &farInBuffer, &outBuffer);
                        (*effectHandle)->process_reverse(effectHandle, &farInBuffer, &outBuffer);
                status != 0) {
                ALOGE("\nError: Process reverse i = %d returned with error %d\n",
                      (int)state.range(1), status);
@@ -241,8 +227,7 @@ static void BM_PREPROCESSING(benchmark::State &state) {

    state.SetComplexityN(state.range(0));

  if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.release_effect(effectHandle);
      status != 0) {
    if (int status = AUDIO_EFFECT_LIBRARY_INFO_SYM.release_effect(effectHandle); status != 0) {
        ALOGE("release_effect returned an error = %d\n", status);
        return;
    }
+388 −387
Original line number Diff line number Diff line
@@ -175,8 +175,8 @@ int preProcCreateEffect(effect_handle_t *pEffectHandle, uint32_t effectType,
    uint32_t replySize = sizeof(reply);
    if (effectType == PREPROC_AEC) {
        (**pEffectHandle)
        ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG_REVERSE, sizeof(effect_config_t), pConfig,
                  &replySize, &reply);
                ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG_REVERSE, sizeof(effect_config_t),
                          pConfig, &replySize, &reply);
    }
    (**pEffectHandle)
            ->command(*pEffectHandle, EFFECT_CMD_SET_CONFIG, sizeof(effect_config_t), pConfig,
@@ -188,8 +188,7 @@ int preProcSetConfigParam(uint32_t paramType, uint32_t paramValue, effect_handle
    int reply = 0;
    uint32_t replySize = sizeof(reply);
    uint32_t paramData[2] = {paramType, paramValue};
  effect_param_t *effectParam =
      (effect_param_t *)malloc(sizeof(*effectParam) + sizeof(paramData));
    effect_param_t* effectParam = (effect_param_t*)malloc(sizeof(*effectParam) + sizeof(paramData));
    memcpy(&effectParam->data[0], &paramData[0], sizeof(paramData));
    effectParam->psize = sizeof(paramData[0]);
    (*effectHandle)
@@ -380,8 +379,8 @@ int main(int argc, const char *argv[]) {
            ALOGE("Invalid AGC Target Level. Error %d\n", status);
            return EXIT_FAILURE;
        }
    if (int status =
            preProcSetConfigParam(AGC_PARAM_COMP_GAIN, (uint32_t)preProcCfgParams.agcCompLevel,
        if (int status = preProcSetConfigParam(AGC_PARAM_COMP_GAIN,
                                               (uint32_t)preProcCfgParams.agcCompLevel,
                                               effectHandle[PREPROC_AGC]);
            status != 0) {
            ALOGE("Invalid AGC Comp Gain. Error %d\n", status);
@@ -454,25 +453,27 @@ int main(int argc, const char *argv[]) {
        for (int i = 0; i < PREPROC_NUM_EFFECTS; i++) {
            if (effectEn[i] == 1) {
                if (i == PREPROC_AEC) {
          if (int status =
                  preProcSetConfigParam(AEC_PARAM_ECHO_DELAY, (uint32_t)preProcCfgParams.aecDelay,
                    if (int status = preProcSetConfigParam(AEC_PARAM_ECHO_DELAY,
                                                           (uint32_t)preProcCfgParams.aecDelay,
                                                           effectHandle[PREPROC_AEC]);
                        status != 0) {
                        ALOGE("preProcSetConfigParam returned Error %d\n", status);
                        return EXIT_FAILURE;
                    }
                }
        if (int status =
                (*effectHandle[i])->process(effectHandle[i], &inputBuffer, &outputBuffer);
                if (int status = (*effectHandle[i])
                                         ->process(effectHandle[i], &inputBuffer, &outputBuffer);
                    status != 0) {
                    ALOGE("\nError: Process i = %d returned with error %d\n", i, status);
                    return EXIT_FAILURE;
                }
                if (i == PREPROC_AEC) {
                    if (int status = (*effectHandle[i])
                               ->process_reverse(effectHandle[i], &farInBuffer, &outputBuffer);
                                             ->process_reverse(effectHandle[i], &farInBuffer,
                                                               &outputBuffer);
                        status != 0) {
            ALOGE("\nError: Process reverse i = %d returned with error %d\n", i, status);
                        ALOGE("\nError: Process reverse i = %d returned with error %d\n", i,
                              status);
                        return EXIT_FAILURE;
                    }
                }