summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2016-10-13 00:19:40 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-13 00:19:40 +0000
commite12085b0c596a85192fb124a0d5f8c652b55a3ef (patch)
tree4893f6efc0e44030f18e7770d0c71c3226479902
parent4eb2a5da1db1481f099d79f1cbb0dd37d90e3bc6 (diff)
parentff3e6f401eb371bd51eaed91bfec1728ec22f3d1 (diff)
downloadmedia-e12085b0c596a85192fb124a0d5f8c652b55a3ef.tar.gz
am: ff3e6f401e Change-Id: I4a9cfe96aac7472dde381cbb8756353d3cd128f2
-rw-r--r--audio_route/audio_route.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/audio_route/audio_route.c b/audio_route/audio_route.c
index 90b114d5..bd5c1124 100644
--- a/audio_route/audio_route.c
+++ b/audio_route/audio_route.c
@@ -420,13 +420,24 @@ static int path_reset(struct audio_route *ar, struct mixer_path *path)
static int mixer_enum_string_to_value(struct mixer_ctl *ctl, const char *string)
{
unsigned int i;
+ unsigned int num_values = mixer_ctl_get_num_enums(ctl);
+
+ if (string == NULL) {
+ ALOGE("NULL enum value string passed to mixer_enum_string_to_value() for ctl %s",
+ mixer_ctl_get_name(ctl));
+ return 0;
+ }
/* Search the enum strings for a particular one */
- for (i = 0; i < mixer_ctl_get_num_enums(ctl); i++) {
+ for (i = 0; i < num_values; i++) {
if (strcmp(mixer_ctl_get_enum_string(ctl, i), string) == 0)
break;
}
-
+ if (i == num_values) {
+ ALOGE("unknown enum value string %s for ctl %s",
+ string, mixer_ctl_get_name(ctl));
+ return 0;
+ }
return i;
}