WebRTC APM: Add missing channel format check
The check was lost in CL https://webrtc-review.googlesource.com/c/src/+/276920 Bug: webrtc:5298 Change-Id: Ic5f072ebef4ad0bdef5446cad0536728b4ad610e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284560 Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38746}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
7daa6787fa
commit
06cba44d7a
@ -201,10 +201,22 @@ std::pair<int, FormatErrorOutputOption> ChooseErrorOutputOption(
|
|||||||
AudioFormatValidity input_validity = ValidateAudioFormat(input_config);
|
AudioFormatValidity input_validity = ValidateAudioFormat(input_config);
|
||||||
AudioFormatValidity output_validity = ValidateAudioFormat(output_config);
|
AudioFormatValidity output_validity = ValidateAudioFormat(output_config);
|
||||||
|
|
||||||
|
if (input_validity == AudioFormatValidity::kValidAndSupported &&
|
||||||
|
output_validity == AudioFormatValidity::kValidAndSupported &&
|
||||||
|
(output_config.num_channels() == 1 ||
|
||||||
|
output_config.num_channels() == input_config.num_channels())) {
|
||||||
|
return {AudioProcessing::kNoError, FormatErrorOutputOption::kDoNothing};
|
||||||
|
}
|
||||||
|
|
||||||
int error_code = AudioFormatValidityToErrorCode(input_validity);
|
int error_code = AudioFormatValidityToErrorCode(input_validity);
|
||||||
if (error_code == AudioProcessing::kNoError) {
|
if (error_code == AudioProcessing::kNoError) {
|
||||||
error_code = AudioFormatValidityToErrorCode(output_validity);
|
error_code = AudioFormatValidityToErrorCode(output_validity);
|
||||||
}
|
}
|
||||||
|
if (error_code == AudioProcessing::kNoError) {
|
||||||
|
// The individual formats are valid but there is some error - must be
|
||||||
|
// channel mismatch.
|
||||||
|
error_code = AudioProcessing::kBadNumberChannelsError;
|
||||||
|
}
|
||||||
|
|
||||||
FormatErrorOutputOption output_option;
|
FormatErrorOutputOption output_option;
|
||||||
if (output_validity != AudioFormatValidity::kValidAndSupported &&
|
if (output_validity != AudioFormatValidity::kValidAndSupported &&
|
||||||
|
@ -3217,6 +3217,16 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
StreamConfig(16000, 3), StreamConfig(16000, 3),
|
StreamConfig(16000, 3), StreamConfig(16000, 3),
|
||||||
ApmFormatHandlingTestParams::ExpectedOutput::kNoError},
|
ApmFormatHandlingTestParams::ExpectedOutput::kNoError},
|
||||||
|
|
||||||
|
// Supported but incompatible formats.
|
||||||
|
ApmFormatHandlingTestParams{
|
||||||
|
StreamConfig(16000, 3), StreamConfig(16000, 2),
|
||||||
|
ApmFormatHandlingTestParams::ExpectedOutput::
|
||||||
|
kErrorAndCopyOfFirstChannel},
|
||||||
|
ApmFormatHandlingTestParams{
|
||||||
|
StreamConfig(16000, 3), StreamConfig(16000, 4),
|
||||||
|
ApmFormatHandlingTestParams::ExpectedOutput::
|
||||||
|
kErrorAndCopyOfFirstChannel},
|
||||||
|
|
||||||
// Unsupported format and input / output mismatch.
|
// Unsupported format and input / output mismatch.
|
||||||
ApmFormatHandlingTestParams{
|
ApmFormatHandlingTestParams{
|
||||||
StreamConfig(7900, 1), StreamConfig(16000, 1),
|
StreamConfig(7900, 1), StreamConfig(16000, 1),
|
||||||
|
Reference in New Issue
Block a user