OSDN Git Service

speaker-test: Fix wrong wave file played back in chmap setup
authorDavid Henningsson <david.henningsson@canonical.com>
Mon, 10 Jun 2013 14:42:48 +0000 (16:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 14 Jun 2013 12:05:23 +0000 (14:05 +0200)
When explicitly specifying channel maps, we need to use that when
loading wave files so the correct file is played back.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
speaker-test/speaker-test.c

index a41b5bd..d35065f 100644 (file)
@@ -771,8 +771,16 @@ static int setup_wav_file(int chn)
 
   if (given_test_wav_file)
     return check_wav_file(chn, given_test_wav_file);
-  else
-    return check_wav_file(chn, wavs[chn]);
+
+#ifdef CONFIG_SUPPORT_CHMAP
+  if (channel_map_set && chn < channel_map->channels) {
+    int channel = channel_map->pos[chn] - SND_CHMAP_FL;
+    if (channel >= 0 && channel < MAX_CHANNELS)
+      return check_wav_file(chn, wavs[channel]);
+  }
+#endif
+
+  return check_wav_file(chn, wavs[chn]);
 }
 
 static int read_wav(uint16_t *buf, int channel, int offset, int bufsize)
@@ -1179,7 +1187,7 @@ int main(int argc, char *argv[]) {
 
     if (test_type == TEST_WAV) {
       for (chn = 0; chn < channels; chn++) {
-       if (setup_wav_file(chn) < 0)
+       if (setup_wav_file(get_speaker_channel(chn)) < 0)
          prg_exit(EXIT_FAILURE);
       }
     }