From d18aebca5b94e991b82382a9f30eca2d7fedbc06 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 15 Dec 2009 15:27:05 +0100 Subject: [PATCH] speaker-test: add -d (--debug) option to show PCM parameters Signed-off-by: Jaroslav Kysela --- speaker-test/speaker-test.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c index e22c937..7859aca 100644 --- a/speaker-test/speaker-test.c +++ b/speaker-test/speaker-test.c @@ -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)