tinymix: fix setting enum str started with digits

For those value strings which are started with digits, they must be set
as enum instead of index value.

Test: with mixer control values started with digits like '48KHz'
Change-Id: I1c70f5613a48d020d3248b71c1e4384f83e33d25
Signed-off-by: HW Lee <hwlee@google.com>
diff --git a/tinymix.c b/tinymix.c
index fc62334..789c4af 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -125,6 +125,16 @@
     return ret;
 }
 
+static int isnumber(const char *str) {
+    char *end;
+
+    if (str == NULL || strlen(str) == 0)
+        return 0;
+
+    strtol(str, &end, 0);
+    return strlen(end) == 0;
+}
+
 static void tinymix_list_controls(struct mixer *mixer)
 {
     struct mixer_ctl *ctl;
@@ -195,7 +205,7 @@
     unsigned int tlv_header_size = 0;
     const char *space = g_tabs_only ? "\t" : " ";
 
-    if (isdigit(control[0]))
+    if (isnumber(control))
         ctl = mixer_get_ctl(mixer, atoi(control));
     else
         ctl = mixer_get_ctl_by_name(mixer, control);
@@ -339,7 +349,7 @@
     unsigned int num_ctl_values;
     unsigned int i;
 
-    if (isdigit(control[0]))
+    if (isnumber(control))
         ctl = mixer_get_ctl(mixer, atoi(control));
     else
         ctl = mixer_get_ctl_by_name(mixer, control);
@@ -357,7 +367,7 @@
         return ENOENT;
     }
 
-    if (isdigit(values[0][0])) {
+    if (isnumber(values[0])) {
         if (num_values == 1) {
             /* Set all values the same */
             int value = atoi(values[0]);