From 9ed7df6bea6e996b7ff2e0d22898425f2ae0feee Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 7 Sep 2017 17:04:57 +0100 Subject: Pull mixer_ctl_get_value out of loop in tinymix_print_enum It is only required to obtain the value of the control once whilst processing tinymix_print_enum. This will significantly reduce the amount of IOCTLs sent for reading an enum control. Signed-off-by: Charles Keepax --- utils/tinymix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/tinymix.c b/utils/tinymix.c index beaab2a..834766b 100644 --- a/utils/tinymix.c +++ b/utils/tinymix.c @@ -177,14 +177,15 @@ static void tinymix_print_enum(struct mixer_ctl *ctl) { unsigned int num_enums; unsigned int i; + unsigned int value; const char *string; num_enums = mixer_ctl_get_num_enums(ctl); + value = mixer_ctl_get_value(ctl, 0); for (i = 0; i < num_enums; i++) { string = mixer_ctl_get_enum_string(ctl, i); - printf("%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ", " : "", - string); + printf("%s%s", value == i ? ", " : "", string); } } -- cgit v1.2.3