Skip to content

Commit

Permalink
s2: Disallow BF/AST when voice_isolation_ui_preferred_effect is NC
Browse files Browse the repository at this point in the history
FIXED=b:383772089
TEST=tast run dut1 audio.CrasNoiseCancellation.\*

Change-Id: I652482d422c3ec212f2f0f96e557b22c524cf997
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/6109885
Tested-by: [email protected] <[email protected]>
Commit-Queue: Hung-Hsien Chen <[email protected]>
Reviewed-by: Hung-Hsien Chen <[email protected]>
  • Loading branch information
afq984 authored and Chromeos LUCI committed Dec 30, 2024
1 parent d61c983 commit 02a4fcf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
17 changes: 17 additions & 0 deletions cras/common/src/types_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ impl EFFECT_TYPE {
_ => c"Invalid NC provider",
}
}

/// Return the set of NC providers for this effect type.
pub fn nc_providers(&self) -> CRAS_NC_PROVIDER {
match self {
&EFFECT_TYPE::NOISE_CANCELLATION => CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP,
&EFFECT_TYPE::STYLE_TRANSFER => {
CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP | CRAS_NC_PROVIDER::AST
}
&EFFECT_TYPE::BEAMFORMING => {
CRAS_NC_PROVIDER::AP
| CRAS_NC_PROVIDER::DSP
| CRAS_NC_PROVIDER::AST
| CRAS_NC_PROVIDER::BF
}
_ => CRAS_NC_PROVIDER::all(),
}
}
}

/// Returns the name of the effect type as a string.
Expand Down
13 changes: 8 additions & 5 deletions cras/server/s2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn resolve(input: &Input) -> Output {
},
};

let mut system_valid_nc_providers = audio_effects_status
let system_valid_nc_providers = audio_effects_status
.iter()
.filter_map(|(provider, status)| {
if status.supported_and_allowed() {
Expand All @@ -199,10 +199,8 @@ fn resolve(input: &Input) -> Output {
None
}
})
.fold(CRAS_NC_PROVIDER::empty(), CRAS_NC_PROVIDER::union);
if input.voice_isolation_ui_preferred_effect == EFFECT_TYPE::STYLE_TRANSFER {
system_valid_nc_providers.remove(CRAS_NC_PROVIDER::BF);
}
.fold(CRAS_NC_PROVIDER::empty(), CRAS_NC_PROVIDER::union)
& input.voice_isolation_ui_preferred_effect.nc_providers();

Output {
audio_effects_ready: input
Expand Down Expand Up @@ -942,6 +940,11 @@ mod tests {
| CRAS_NC_PROVIDER::AST
| CRAS_NC_PROVIDER::BF
);
s.set_voice_isolation_ui_preferred_effect(EFFECT_TYPE::NOISE_CANCELLATION);
assert_eq!(
s.output.system_valid_nc_providers,
CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP
);
}

#[test]
Expand Down

0 comments on commit 02a4fcf

Please sign in to comment.