Skip to content

Commit

Permalink
CRAS: Move CrasProcessorEffect into types_internal.rs
Browse files Browse the repository at this point in the history
This is for s2 to access CrasProcessorEffect and avoid cyclic
dependency.
s2 will handle stream effect resolving, which needs access of
CrasProcessorEffect.

BUG=b:353627012
TEST=bazel test //... --config=local-clang --//:apm

Change-Id: I1b7de6e8c255442306fa833d1af9f55aa4dd1204
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5881346
Reviewed-by: Cranel W <cranelw@chromium.org>
Reviewed-by: Pin-chih Lin <johnylin@google.com>
Commit-Queue: Hung-Hsien Chen <hunghsienchen@chromium.org>
Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com>
Reviewed-by: Li-Yu Yu <aaronyu@google.com>
  • Loading branch information
hunghsienchen authored and Chromeos LUCI committed Oct 7, 2024
1 parent 070ee6c commit 504b40d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
9 changes: 9 additions & 0 deletions cras/common/rust_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ enum CRAS_FRA_SIGNAL {
SecondaryHciDeviceChanged,
};

enum CrasProcessorEffect {
NoEffects,
Negate,
NoiseCancellation,
StyleTransfer,
Beamforming,
Overridden,
};

struct cras_fra_kv_t {
const char *key;
const char *value;
Expand Down
11 changes: 11 additions & 0 deletions cras/common/src/types_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ use bitflags::bitflags;
use itertools::Itertools;
use serde::Serialize;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CrasProcessorEffect {
NoEffects,
Negate,
NoiseCancellation,
StyleTransfer,
Beamforming,
Overridden,
}

bitflags! {
#[allow(non_camel_case_types)]
#[repr(transparent)]
Expand Down
1 change: 1 addition & 0 deletions cras/src/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ cc_library(
"//cras/src/common",
"//cras/src/dsp",
"//cras/src/server/rust:cc",
"//cras/common:rust_common_cc",
] + select({
"//:apm_build": ["@webrtc_apm//webrtc_apm"],
"//conditions:default": [],
Expand Down
7 changes: 6 additions & 1 deletion cras/src/server/rust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cc_test(
deps = [
":cc",
"//audio_processor/c:plugin_processor",
"//cras/common:rust_common_cc",
"@pkg_config//gtest",
"@pkg_config//gtest_main",
],
Expand All @@ -71,7 +72,11 @@ cras_cbindgen(
name = "cras_processor_h",
srcs = ["src/cras_processor.rs"],
out = "include/cras_processor.h",
extra_args = ["--with-include=audio_processor/c/plugin_processor.h"],
extra_args = [
"--with-include=audio_processor/c/plugin_processor.h",
"--with-include=cras/common/rust_common.h",
"--add-keyword-enum",
],
)

cras_cbindgen(
Expand Down
10 changes: 1 addition & 9 deletions cras/src/server/rust/include/cras_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ extern "C" {
#include <stdint.h>
#include <stdlib.h>
#include "audio_processor/c/plugin_processor.h"

enum CrasProcessorEffect {
NoEffects,
Negate,
NoiseCancellation,
StyleTransfer,
Beamforming,
Overridden,
};
#include "cras/common/rust_common.h"

struct CrasProcessorCreateResult {
/**
Expand Down
12 changes: 1 addition & 11 deletions cras/src/server/rust/src/cras_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,12 @@ use audio_processor::AudioProcessor;
use audio_processor::Format;
use audio_processor::ProcessorVec;
use cras_common::types_internal::CrasDlcId;
use cras_common::types_internal::CrasProcessorEffect;
use cras_dlc::get_dlc_state_cached;
use cras_s2::BEAMFORMING_CONFIG_PATH;

mod processor_override;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CrasProcessorEffect {
NoEffects,
Negate,
NoiseCancellation,
StyleTransfer,
Beamforming,
Overridden,
}

#[repr(C)]
#[derive(Clone, Debug)]
pub struct CrasProcessorConfig {
Expand Down
7 changes: 5 additions & 2 deletions rules/cbindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ fn main() {
.rename_item("DRC_PARAM", "drc_param")
.include_item("DRC_PARAM")
.include_item("CrasDlcId")
.include_item("EFFECT_TYPE");
.include_item("EFFECT_TYPE")
.include_item("CrasProcessorEffect");

let mut b = b;

if c.add_keyword_enum {
b = b.rename_item("CrasDlcId", "enum CrasDlcId");
b = b
.rename_item("CrasDlcId", "enum CrasDlcId")
.rename_item("CrasProcessorEffect", "enum CrasProcessorEffect");
}

for src in c.with_src {
Expand Down

0 comments on commit 504b40d

Please sign in to comment.