]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: add support for G.711 A_LAW enconding in AU file format
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 2 Apr 2025 06:07:18 +0000 (08:07 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 8 Jan 2026 13:16:34 +0000 (14:16 +0100)
At the time being, aplay only supports G.711 ยต-law, 8-bits PCM and
16-bits PCM encodings for the AU format while the AU format supports
many more.

In Europe the most G.711 used encoding is the A-law, which is also
part of the encodings supported by the AU file format.

Add support for that encoding in aplay.

Closes: https://github.com/alsa-project/alsa-utils/pull/297
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
aplay/aplay.c
aplay/formats.h

index 737d0878fc5c978fdd160858fcfe6ac4d2431b63..0050032dfcebb38afcc808af362535b45c02e8cb 100644 (file)
@@ -1245,6 +1245,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;
        }
@@ -2787,6 +2793,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);
index d82505e4626fbcb07aa63308d315db3f7ce59f66..c5408f2b0a46393c51747e16195788d230dd1aa6 100644 (file)
@@ -120,6 +120,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 {
        uint32_t magic;         /* '.snd' */