diff --git a/cras/common/rust_common.h b/cras/common/rust_common.h index d416f4e7c..5910d7f42 100644 --- a/cras/common/rust_common.h +++ b/cras/common/rust_common.h @@ -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; diff --git a/cras/common/src/types_internal.rs b/cras/common/src/types_internal.rs index 7a38fda84..fa2ecdfa0 100644 --- a/cras/common/src/types_internal.rs +++ b/cras/common/src/types_internal.rs @@ -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)] diff --git a/cras/src/server/BUILD.bazel b/cras/src/server/BUILD.bazel index e7966262d..b0ef150d6 100644 --- a/cras/src/server/BUILD.bazel +++ b/cras/src/server/BUILD.bazel @@ -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": [], diff --git a/cras/src/server/rust/BUILD.bazel b/cras/src/server/rust/BUILD.bazel index 6f74f77d6..77613555d 100644 --- a/cras/src/server/rust/BUILD.bazel +++ b/cras/src/server/rust/BUILD.bazel @@ -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", ], @@ -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( diff --git a/cras/src/server/rust/include/cras_processor.h b/cras/src/server/rust/include/cras_processor.h index 174011834..a130deeba 100644 --- a/cras/src/server/rust/include/cras_processor.h +++ b/cras/src/server/rust/include/cras_processor.h @@ -18,15 +18,7 @@ extern "C" { #include #include #include "audio_processor/c/plugin_processor.h" - -enum CrasProcessorEffect { - NoEffects, - Negate, - NoiseCancellation, - StyleTransfer, - Beamforming, - Overridden, -}; +#include "cras/common/rust_common.h" struct CrasProcessorCreateResult { /** diff --git a/cras/src/server/rust/src/cras_processor.rs b/cras/src/server/rust/src/cras_processor.rs index ad7e2101e..cedfe77aa 100644 --- a/cras/src/server/rust/src/cras_processor.rs +++ b/cras/src/server/rust/src/cras_processor.rs @@ -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 { diff --git a/rules/cbindgen/src/main.rs b/rules/cbindgen/src/main.rs index d9e6145e7..e9452b8d7 100644 --- a/rules/cbindgen/src/main.rs +++ b/rules/cbindgen/src/main.rs @@ -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 {