]> git.alsa-project.org Git - alsa-utils.git/commitdiff
speaker-test: add -d (--debug) option to show PCM parameters
authorJaroslav Kysela <perex@perex.cz>
Tue, 15 Dec 2009 14:27:05 +0000 (15:27 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 15 Dec 2009 14:27:05 +0000 (15:27 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
speaker-test/speaker-test.c

index e22c9373db224858c43feb6e46edb4febfca7f9e..7859aca8565718d4b830ec4c938489c3b0b9c4d3 100644 (file)
@@ -97,6 +97,7 @@ static snd_pcm_uframes_t  buffer_size;
 static snd_pcm_uframes_t  period_size;
 static const char *given_test_wav_file = NULL;
 static char *wav_file_dir = SOUNDSDIR;
+static int debug = 0;
 
 static const char *const channel_name[MAX_CHANNELS] = {
   /*  0 */ N_("Front Left"),
@@ -775,6 +776,7 @@ int main(int argc, char *argv[]) {
     {"speaker",   1, NULL, 's'},
     {"wavfile",   1, NULL, 'w'},
     {"wavdir",    1, NULL, 'W'},
+    {"debug",    0, NULL, 'd'},
     {NULL,        0, NULL, 0  },
   };
 
@@ -793,7 +795,7 @@ int main(int argc, char *argv[]) {
   while (1) {
     int c;
     
-    if ((c = getopt_long(argc, argv, "hD:r:c:f:F:b:p:P:t:l:s:w:W:", long_option, NULL)) < 0)
+    if ((c = getopt_long(argc, argv, "hD:r:c:f:F:b:p:P:t:l:s:w:W:d", long_option, NULL)) < 0)
       break;
     
     switch (c) {
@@ -872,6 +874,9 @@ int main(int argc, char *argv[]) {
     case 'W':
       wav_file_dir = optarg;
       break;
+    case 'd':
+      debug = 1;
+      break;
     default:
       fprintf(stderr, _("Unknown option '%c'\n"), c);
       exit(EXIT_FAILURE);
@@ -917,6 +922,14 @@ int main(int argc, char *argv[]) {
     snd_pcm_close(handle);
     exit(EXIT_FAILURE);
   }
+  if (debug) {
+    snd_output_t *log;
+    err = snd_output_stdio_attach(&log, stderr, 0);
+    if (err >= 0) {
+      snd_pcm_dump(handle, log);
+      snd_output_close(log);
+    }
+  }
 
   frames = malloc(snd_pcm_frames_to_bytes(handle, period_size));
   if (test_type == TEST_PINK_NOISE)