From 7255fbcdcd0b7fafecd072d4a144f2549958f9c5 Mon Sep 17 00:00:00 2001 From: Li-Yu Yu Date: Mon, 13 Nov 2023 10:26:31 +0000 Subject: [PATCH] processor_override: Give input its own message BUG=b:273232671 TEST=uncomment input.enabled in /etc/cras/processor_override.txtpb Change-Id: I11aeab35146268f91f2e752522f0e005595a5bd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5020343 Auto-Submit: Li-Yu Yu Reviewed-by: Chih-Yang Hsia Commit-Queue: Chih-Yang Hsia Tested-by: Li-Yu Yu Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com --- cras-config/processor_override.txtpb | 28 +++++++++++-------- .../server/rust/proto/cras_processor.proto | 6 +++- cras/src/server/rust/src/cras_processor.rs | 4 +-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cras-config/processor_override.txtpb b/cras-config/processor_override.txtpb index dc99554f3..9c67a005c 100644 --- a/cras-config/processor_override.txtpb +++ b/cras-config/processor_override.txtpb @@ -1,15 +1,19 @@ -# Uncomment the following line to override CRAS processing. -# enabled: true +# Input processing override. +input { + # Uncomment the following line to override CRAS input processing. + # enabled: true -# Block size of the processor. -# If 0, use the block size that cras_stream_apm is using. -block_size: 480 -# Frame rate of the processor. -# If 0, use the rate that CRAS is using and no resampling is done. -frame_rate: 48000 + # Block size of the processor. + # If 0, use the block size that cras_stream_apm is using. + block_size: 480 + # Frame rate of the processor. + # If 0, use the rate that CRAS is using and no resampling is done. + frame_rate: 48000 -# The path to the plugin shared library. -plugin_path: "/usr/local/lib64/libtest_plugins.so" + # The path to the plugin shared library. + plugin_path: "/usr/local/lib64/libtest_plugins.so" -# The name of the function to create the plugin processor. -constructor: "abs_processor_create" + # The name of the function to create the plugin processor. + constructor: "abs_processor_create" + # constructor: "plugin_processor_create" +} diff --git a/cras/src/server/rust/proto/cras_processor.proto b/cras/src/server/rust/proto/cras_processor.proto index ea2a94b9d..799ad4683 100644 --- a/cras/src/server/rust/proto/cras_processor.proto +++ b/cras/src/server/rust/proto/cras_processor.proto @@ -1,9 +1,13 @@ syntax = "proto3"; -message CrasProcessorOverride { +message Plugin { bool enabled = 1; uint32 block_size = 2; uint32 frame_rate = 3; string plugin_path = 4; string constructor = 5; } + +message CrasProcessorOverride { + Plugin input = 1; +} diff --git a/cras/src/server/rust/src/cras_processor.rs b/cras/src/server/rust/src/cras_processor.rs index 10248f52e..935957851 100644 --- a/cras/src/server/rust/src/cras_processor.rs +++ b/cras/src/server/rust/src/cras_processor.rs @@ -70,7 +70,7 @@ static GLOBAL_ID_COUNTER: AtomicUsize = AtomicUsize::new(0); impl CrasProcessor { fn new(mut config: CrasProcessorConfig) -> anyhow::Result { - let override_config = processor_override::read_system_config(); + let override_config = processor_override::read_system_config().input; if override_config.enabled { config.effect = CrasProcessorEffect::Overridden; } @@ -275,5 +275,5 @@ pub unsafe extern "C" fn cras_processor_create( /// Returns true if override is enabled in the system config file. #[no_mangle] pub extern "C" fn cras_processor_is_override_enabled() -> bool { - processor_override::read_system_config().enabled + processor_override::read_system_config().input.enabled }