OSDN Git Service

Snap for 4793185 from 3fd8ae99b441b6b50bc8cb60bd4326b52aa70b8c to pi-release
[android-x86/system-media.git] / audio_route / audio_route.c
index f62609f..700af61 100644 (file)
@@ -384,6 +384,7 @@ static int path_apply(struct audio_route *ar, struct mixer_path *path)
     struct mixer_ctl *ctl;
     enum mixer_ctl_type type;
 
+    ALOGD("Apply path: %s", path->name != NULL ? path->name : "none");
     for (i = 0; i < path->length; i++) {
         ctl_index = path->setting[i].ctl_index;
         ctl = index_to_ctl(ar, ctl_index);
@@ -405,6 +406,7 @@ static int path_reset(struct audio_route *ar, struct mixer_path *path)
     struct mixer_ctl *ctl;
     enum mixer_ctl_type type;
 
+    ALOGV("Reset path: %s", path->name != NULL ? path->name : "none");
     for (i = 0; i < path->length; i++) {
         ctl_index = path->setting[i].ctl_index;
         ctl = index_to_ctl(ar, ctl_index);
@@ -782,7 +784,6 @@ int audio_route_reset_path(struct audio_route *ar, const char *name)
 static int audio_route_update_path(struct audio_route *ar, const char *name, bool reverse)
 {
     struct mixer_path *path;
-    int32_t i, end;
     unsigned int j;
 
     if (!ar) {
@@ -796,14 +797,12 @@ static int audio_route_update_path(struct audio_route *ar, const char *name, boo
         return -1;
     }
 
-    i = reverse ? (path->length - 1) : 0;
-    end = reverse ? -1 : (int32_t)path->length;
 
-    while (i != end) {
+    for (size_t i = 0; i < path->length; ++i) {
         unsigned int ctl_index;
         enum mixer_ctl_type type;
 
-        ctl_index = path->setting[i].ctl_index;
+        ctl_index = path->setting[reverse ? path->length - 1 - i : i].ctl_index;
 
         struct mixer_state * ms = &ar->mixer_state[ctl_index];
 
@@ -834,8 +833,6 @@ static int audio_route_update_path(struct audio_route *ar, const char *name, boo
                 break;
             }
         }
-
-        i = reverse ? (i - 1) : (i + 1);
     }
     return 0;
 }