-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use board.ini to tell whether beamforming is supported
FIXED=b:339785214 TEST=tast run dut14 audio.CrasEffects.beamforming_\* TEST=audio_diagnostics Cq-Depend: chromium:6040873 Change-Id: I1bd1feb291c8735276781834735e49edee94fd4e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/6041034 Commit-Queue: Li-Yu Yu <aaronyu@google.com> Reviewed-by: Hung-Hsien Chen <hunghsienchen@chromium.org> Tested-by: Li-Yu Yu <aaronyu@google.com>
- Loading branch information
Showing
8 changed files
with
141 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2024 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
use std::collections::HashSet; | ||
use std::path::Path; | ||
use std::path::PathBuf; | ||
|
||
use anyhow::Context; | ||
use audio_processor::cdcfg; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
pub enum BeamformingConfig { | ||
Supported(BeamformingProperties), | ||
Unsupported { reason: String }, | ||
} | ||
|
||
impl Default for BeamformingConfig { | ||
fn default() -> Self { | ||
BeamformingConfig::Unsupported { | ||
reason: "not probed yet".to_string(), | ||
} | ||
} | ||
} | ||
|
||
impl BeamformingConfig { | ||
pub fn probe(cras_config_dir: &str) -> Self { | ||
match BeamformingProperties::probe(cras_config_dir) { | ||
Ok(properties) => Self::Supported(properties), | ||
Err(err) => Self::Unsupported { | ||
reason: format!("{err:#}"), | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Default, Serialize)] | ||
pub struct BeamformingProperties { | ||
/// The pipeline path to use for beamforming. | ||
pub pipeline_path: PathBuf, | ||
/// The set of DLCs required for beamforming to function. | ||
pub required_dlcs: HashSet<String>, | ||
} | ||
|
||
impl BeamformingProperties { | ||
fn probe(cras_config_dir: &str) -> anyhow::Result<Self> { | ||
let board_ini = cras_ini::parse_file( | ||
&Path::new("/etc/cras") | ||
.join(cras_config_dir) | ||
.join("board.ini"), | ||
) | ||
.context("cannot parse board.ini")?; | ||
let pipeline_file = board_ini | ||
.get("processing") | ||
.context("processing section not found in board.ini")? | ||
.get("beamforming_pipeline_file") | ||
.context("beamforming_pipeline_file not found in [processing] in board.ini")? | ||
.as_str() | ||
.to_string(); | ||
let pipeline_path = Path::new("/etc/cras/processor").join(&pipeline_file); | ||
let required_dlcs = cdcfg::get_required_dlcs(&pipeline_path) | ||
.context("cannot get required DLCs from pipeline file")?; | ||
Ok(BeamformingProperties { | ||
pipeline_path, | ||
required_dlcs, | ||
}) | ||
} | ||
} |