Skip to content

Commit 02a4fcf

Browse files
afq984Chromeos LUCI
authored andcommitted
s2: Disallow BF/AST when voice_isolation_ui_preferred_effect is NC
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: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com> Commit-Queue: Hung-Hsien Chen <hunghsienchen@chromium.org> Reviewed-by: Hung-Hsien Chen <hunghsienchen@chromium.org>
1 parent d61c983 commit 02a4fcf

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

cras/common/src/types_internal.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,23 @@ impl EFFECT_TYPE {
134134
_ => c"Invalid NC provider",
135135
}
136136
}
137+
138+
/// Return the set of NC providers for this effect type.
139+
pub fn nc_providers(&self) -> CRAS_NC_PROVIDER {
140+
match self {
141+
&EFFECT_TYPE::NOISE_CANCELLATION => CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP,
142+
&EFFECT_TYPE::STYLE_TRANSFER => {
143+
CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP | CRAS_NC_PROVIDER::AST
144+
}
145+
&EFFECT_TYPE::BEAMFORMING => {
146+
CRAS_NC_PROVIDER::AP
147+
| CRAS_NC_PROVIDER::DSP
148+
| CRAS_NC_PROVIDER::AST
149+
| CRAS_NC_PROVIDER::BF
150+
}
151+
_ => CRAS_NC_PROVIDER::all(),
152+
}
153+
}
137154
}
138155

139156
/// Returns the name of the effect type as a string.

cras/server/s2/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fn resolve(input: &Input) -> Output {
190190
},
191191
};
192192

193-
let mut system_valid_nc_providers = audio_effects_status
193+
let system_valid_nc_providers = audio_effects_status
194194
.iter()
195195
.filter_map(|(provider, status)| {
196196
if status.supported_and_allowed() {
@@ -199,10 +199,8 @@ fn resolve(input: &Input) -> Output {
199199
None
200200
}
201201
})
202-
.fold(CRAS_NC_PROVIDER::empty(), CRAS_NC_PROVIDER::union);
203-
if input.voice_isolation_ui_preferred_effect == EFFECT_TYPE::STYLE_TRANSFER {
204-
system_valid_nc_providers.remove(CRAS_NC_PROVIDER::BF);
205-
}
202+
.fold(CRAS_NC_PROVIDER::empty(), CRAS_NC_PROVIDER::union)
203+
& input.voice_isolation_ui_preferred_effect.nc_providers();
206204

207205
Output {
208206
audio_effects_ready: input
@@ -942,6 +940,11 @@ mod tests {
942940
| CRAS_NC_PROVIDER::AST
943941
| CRAS_NC_PROVIDER::BF
944942
);
943+
s.set_voice_isolation_ui_preferred_effect(EFFECT_TYPE::NOISE_CANCELLATION);
944+
assert_eq!(
945+
s.output.system_valid_nc_providers,
946+
CRAS_NC_PROVIDER::AP | CRAS_NC_PROVIDER::DSP
947+
);
945948
}
946949

947950
#[test]

0 commit comments

Comments
 (0)