Skip to contentSkip to conversation

[PATCH - report available sample formats in aplay/arecord when currently selected one doesn't work]

PATCH In review [email protected] 2 participants 2 messages Oct 18, 2009 – Nov 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [PATCH - report available sample formats in aplay/arecord when currently selected one doesn't work]

From: Arnout Engelen <[email protected]>

---
 aplay/aplay.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
aplay/aplay.c +15 -0
index c7c82a1..60f17de 100644
@@ -941,6 +941,20 @@ static int test_au(int fd, void *buffer)
 	return 0;
 }
 
+static void show_available_sample_formats(snd_pcm_hw_params_t* params)
+{
+	snd_pcm_format_t format;
+
+	fprintf(stderr, "Available formats:\n");
+	for (format = 0; format < SND_PCM_FORMAT_LAST; format++)
+	{
+		if (snd_pcm_hw_params_test_format(handle, params, format) == 0)
+		{
+			fprintf(stderr, "- %s\n", snd_pcm_format_name(format));
+		}
+	}
+}
+
 static void set_params(void)
 {
 	snd_pcm_hw_params_t *params;
@@ -977,6 +991,7 @@ static void set_params(void)
 	err = snd_pcm_hw_params_set_format(handle, params, hwparams.format);
 	if (err < 0) {
 		error(_("Sample format non available"));
+		show_available_sample_formats(params);
 		exit(EXIT_FAILURE);
 	}
 	err = snd_pcm_hw_params_set_channels(handle, params, hwparams.channels);
Signature · 1 line
1.6.3.3
#1 lore raw

At Sun, 18 Oct 2009 21:34:30 +0200,

Quoted 5 lines · [email protected] wrote:

From: Arnout Engelen <[email protected]>

Thanks for the patch.
Now applied with minor coding-style fixes.

Takashi

Quoted 40 lines
---
 aplay/aplay.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
aplay/aplay.c +15 -0
index c7c82a1..60f17de 100644
@@ -941,6 +941,20 @@ static int test_au(int fd, void *buffer)
 	return 0;
 }
 
+static void show_available_sample_formats(snd_pcm_hw_params_t* params)
+{
+	snd_pcm_format_t format;
+
+	fprintf(stderr, "Available formats:\n");
+	for (format = 0; format < SND_PCM_FORMAT_LAST; format++)
+	{
+		if (snd_pcm_hw_params_test_format(handle, params, format) == 0)
+		{
+			fprintf(stderr, "- %s\n", snd_pcm_format_name(format));
+		}
+	}
+}
+
 static void set_params(void)
 {
 	snd_pcm_hw_params_t *params;
@@ -977,6 +991,7 @@ static void set_params(void)
 	err = snd_pcm_hw_params_set_format(handle, params, hwparams.format);
 	if (err < 0) {
 		error(_("Sample format non available"));
+		show_available_sample_formats(params);
 		exit(EXIT_FAILURE);
 	}
 	err = snd_pcm_hw_params_set_channels(handle, params, hwparams.channels);
Signature · 1 line
1.6.3.3