alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: alsa-devel@alsa-project.org, Jaroslav Kysela <perex@perex.cz>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Subject: [PATCH] aplay: Add support for G711 A law on .au files
Date: Wed, 10 Aug 2022 11:25:40 +0200	[thread overview]
Message-ID: <20220810092540.340279-1-christophe.leroy@csgroup.eu> (raw)

.au files support G711 A law as well. Add it to aplay.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 aplay/aplay.c   | 9 +++++++++
 aplay/formats.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/aplay/aplay.c b/aplay/aplay.c
index 6ce7191..c004bf9 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1210,6 +1210,12 @@ static int test_au(int fd, void *buffer)
 			fprintf(stderr, _("Warning: format is changed to S16_BE\n"));
 		hwparams.format = SND_PCM_FORMAT_S16_BE;
 		break;
+	case AU_FMT_ALAW:
+		if (hwparams.format != DEFAULT_FORMAT &&
+		    hwparams.format != SND_PCM_FORMAT_A_LAW)
+			fprintf(stderr, _("Warning: format is changed to A_LAW\n"));
+		hwparams.format = SND_PCM_FORMAT_A_LAW;
+		break;
 	default:
 		return -1;
 	}
@@ -2735,6 +2741,9 @@ static void begin_au(int fd, size_t cnt)
 	case SND_PCM_FORMAT_S16_BE:
 		ah.encoding = BE_INT(AU_FMT_LIN16);
 		break;
+	case SND_PCM_FORMAT_A_LAW:
+		ah.encoding = BE_INT(AU_FMT_ALAW);
+		break;
 	default:
 		error(_("Sparc Audio doesn't support %s format..."), snd_pcm_format_name(hwparams.format));
 		prg_exit(EXIT_FAILURE);
diff --git a/aplay/formats.h b/aplay/formats.h
index ac0a2b0..cbc99fe 100644
--- a/aplay/formats.h
+++ b/aplay/formats.h
@@ -121,6 +121,7 @@ typedef struct {
 #define AU_FMT_ULAW		1
 #define AU_FMT_LIN8		2
 #define AU_FMT_LIN16		3
+#define AU_FMT_ALAW		27
 
 typedef struct au_header {
 	u_int magic;		/* '.snd' */
-- 
2.37.1


                 reply	other threads:[~2022-08-10  9:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220810092540.340279-1-christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).