OSDN Git Service

Added snd_pcm_get_format_name() to alsa-lib.
authorJaroslav Kysela <perex@perex.cz>
Sat, 11 Dec 1999 20:36:13 +0000 (20:36 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sat, 11 Dec 1999 20:36:13 +0000 (20:36 +0000)
include/pcm.h
src/pcm/pcm_misc.c

index f277a7a..be487eb 100644 (file)
@@ -57,6 +57,7 @@ int snd_pcm_format_little_endian(int format);
 int snd_pcm_format_big_endian(int format);
 int snd_pcm_format_width(int format);          /* in bits */
 ssize_t snd_pcm_format_size(int format, size_t samples);
+const char *snd_pcm_get_format_name(int format);
 
 #ifdef __cplusplus
 }
index e3c7048..30a903d 100644 (file)
@@ -191,3 +191,39 @@ ssize_t snd_pcm_format_size(int format, size_t samples)
                return -EINVAL;
        }
 }
+
+const char *snd_pcm_get_format_name(int format)
+{
+       static char *formats[] = {
+               "Signed 8-bit",
+               "Unsigned 8-bit",
+               "Signed 16-bit Little Endian",
+               "Signed 16-bit Big Endian",
+               "Unsigned 16-bit Little Endian",
+               "Unsigned 16-bit Big Endian",
+               "Signed 24-bit Little Endian",
+               "Signed 24-bit Big Endian",
+               "Unsigned 24-bit Little Endian",
+               "Unsigned 24-bit Big Endian",
+               "Signed 32-bit Little Endian",
+               "Signed 32-bit Big Endian",
+               "Unsigned 32-bit Little Endian",
+               "Unsigned 32-bit Big Endian",
+               "Float Little Endian",
+               "Float Big Endian",
+               "Float64 Little Endian",
+               "Float64 Big Endian",
+               "IEC-958 Little Endian",
+               "IEC-958 Big Endian",
+               "Mu-Law",
+               "A-Law",
+               "Ima-ADPCM",
+               "MPEG",
+               "GSM"
+       };
+       if (format == SND_PCM_SFMT_SPECIAL)
+               return "Special";
+       if (format < 0 || format > SND_PCM_SFMT_GSM)
+               return "Unknown";
+       return formats[format];
+}