diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-07 16:53:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-07 16:53:24 +0000 |
commit | 4f97d6740411fb53a4fb5f6e1af03e1f1b28c1ba (patch) | |
tree | 7e0e07b9d8d50fc5dd352d5b36d74fa3cb3427db /cras/src/common/cras_audio_format.c | |
parent | 8d2c5b2edb9023b91d79709f2900ee1b643a3127 (diff) | |
parent | 8cfb92904b40ff98c82dd5309698999a28c91388 (diff) | |
download | adhd-4f97d6740411fb53a4fb5f6e1af03e1f1b28c1ba.tar.gz |
Snap for 7803083 from 8cfb92904b40ff98c82dd5309698999a28c91388 to mainline-tzdata2-release
Change-Id: Ice40f0028ec451c06ea7097e88c4152da1105d57
Diffstat (limited to 'cras/src/common/cras_audio_format.c')
-rw-r--r-- | cras/src/common/cras_audio_format.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cras/src/common/cras_audio_format.c b/cras/src/common/cras_audio_format.c index f504dfc3..8bd48656 100644 --- a/cras/src/common/cras_audio_format.c +++ b/cras/src/common/cras_audio_format.c @@ -62,7 +62,7 @@ int cras_audio_format_set_channel_layout(struct cras_audio_format *format, * channel count set in format. */ for (i = 0; i < CRAS_CH_MAX; i++) - if (layout[i] >= (int)format->num_channels) + if (layout[i] < -1 || layout[i] >= (int)format->num_channels) return -EINVAL; for (i = 0; i < CRAS_CH_MAX; i++) @@ -71,6 +71,19 @@ int cras_audio_format_set_channel_layout(struct cras_audio_format *format, return 0; } +/* Verifies if all channel_layout[i] are in [-1, fmt->num_channels). */ +bool cras_audio_format_valid(const struct cras_audio_format *fmt) +{ + int i; + for (i = 0; i < CRAS_CH_MAX; i++) { + if (fmt->channel_layout[i] < -1 || + fmt->channel_layout[i] >= (int)fmt->num_channels) { + return false; + } + } + return true; +} + /* Destroy an audio format struct created with cras_audio_format_crate. */ void cras_audio_format_destroy(struct cras_audio_format *fmt) { |