]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added snd_pcm_format_physical_width...
authorJaroslav Kysela <perex@perex.cz>
Thu, 30 Mar 2000 13:21:26 +0000 (13:21 +0000)
committerJaroslav Kysela <perex@perex.cz>
Thu, 30 Mar 2000 13:21:26 +0000 (13:21 +0000)
include/pcm.h
src/pcm/pcm_misc.c
src/pcm/pcm_plugin.c

index 4bd9a211204d332be5583f75a0c33f39a9258aef..9299a17377d0843fdf3ca6272ba44e4e5c21b676 100644 (file)
@@ -54,7 +54,8 @@ int snd_pcm_format_unsigned(int format);
 int snd_pcm_format_linear(int format);
 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 */
+int snd_pcm_format_width(int format);                  /* in bits */
+int snd_pcm_format_physical_width(int format);         /* in bits */
 int snd_pcm_build_linear_format(int width, int unsignd, int big_endian);
 ssize_t snd_pcm_format_size(int format, size_t samples);
 unsigned char snd_pcm_format_silence(int format);
index f2e18949eacf13a878a72442ae8c4f52d3711a31..707f24a3ea13771d09c6c6d7b5e88c1bc91fbcad 100644 (file)
@@ -148,6 +148,43 @@ int snd_pcm_format_width(int format)
        }
 }
 
+int snd_pcm_format_physical_width(int format)
+{
+       switch (format) {
+       case SND_PCM_SFMT_S8:
+       case SND_PCM_SFMT_U8:
+               return 8;
+       case SND_PCM_SFMT_S16_LE:
+       case SND_PCM_SFMT_S16_BE:
+       case SND_PCM_SFMT_U16_LE:
+       case SND_PCM_SFMT_U16_BE:
+               return 16;
+       case SND_PCM_SFMT_S24_LE:
+       case SND_PCM_SFMT_S24_BE:
+       case SND_PCM_SFMT_U24_LE:
+       case SND_PCM_SFMT_U24_BE:
+       case SND_PCM_SFMT_S32_LE:
+       case SND_PCM_SFMT_S32_BE:
+       case SND_PCM_SFMT_U32_LE:
+       case SND_PCM_SFMT_U32_BE:
+       case SND_PCM_SFMT_FLOAT_LE:
+       case SND_PCM_SFMT_FLOAT_BE:
+       case SND_PCM_SFMT_IEC958_SUBFRAME_LE:
+       case SND_PCM_SFMT_IEC958_SUBFRAME_BE:
+               return 32;
+       case SND_PCM_SFMT_FLOAT64_LE:
+       case SND_PCM_SFMT_FLOAT64_BE:
+               return 64;
+       case SND_PCM_SFMT_MU_LAW:
+       case SND_PCM_SFMT_A_LAW:
+               return 8;
+       case SND_PCM_SFMT_IMA_ADPCM:
+               return 4;
+       default:
+               return -EINVAL;
+       }
+}
+
 ssize_t snd_pcm_format_size(int format, size_t samples)
 {
        if (samples < 0)
index 66ff8e6518752324db415eba412b6c2299dab202..3b765f049ec6eeccdab2c8ffa49870b9799d8f4e 100644 (file)
@@ -53,12 +53,12 @@ snd_pcm_plugin_t *snd_pcm_plugin_build(snd_pcm_plugin_handle_t *handle,
        plugin->name = name ? strdup(name) : NULL;
        if (src_format) {
                memcpy(&plugin->src_format, src_format, sizeof(snd_pcm_format_t));
-               if ((plugin->src_width = snd_pcm_format_width(src_format->format)) < 0)
+               if ((plugin->src_width = snd_pcm_format_physical_width(src_format->format)) < 0)
                        return NULL;
        }
        if (dst_format) {
                memcpy(&plugin->dst_format, dst_format, sizeof(snd_pcm_format_t));
-               if ((plugin->dst_width = snd_pcm_format_width(dst_format->format)) < 0)
+               if ((plugin->dst_width = snd_pcm_format_physical_width(dst_format->format)) < 0)
                        return NULL;
        }
        plugin->handle = handle;
@@ -771,7 +771,7 @@ static int snd_pcm_plugin_xvoices(snd_pcm_plugin_t *plugin,
        snd_pcm_plugin_voice_t *v;
        
        *voices = NULL;
-       if ((width = snd_pcm_format_width(format->format)) < 0)
+       if ((width = snd_pcm_format_physical_width(format->format)) < 0)
                return width;   
        size = format->voices * samples * width;
        if ((size % 8) != 0)