]> git.alsa-project.org Git - alsa-lib.git/commitdiff
dmix: fix interleaved check
authorClemens Ladisch <clemens@ladisch.de>
Mon, 19 Dec 2005 07:40:15 +0000 (07:40 +0000)
committerClemens Ladisch <clemens@ladisch.de>
Mon, 19 Dec 2005 07:40:15 +0000 (07:40 +0000)
When checking that samples are properly interleaved, use the actual
sample size instead of always assuming 16 bits.

src/pcm/pcm_direct.c

index 535cc29fc80b2f55ab88bee716c6869e7d872ab7..a3eedc25e9bf45398e67312263d7feaa18fc7062 100644 (file)
@@ -1143,11 +1143,12 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
 int snd_pcm_direct_check_interleave(snd_pcm_direct_t *dmix, snd_pcm_t *pcm)
 {
        unsigned int chn, channels;
-       int interleaved = 1;
+       int bits, interleaved = 1;
        const snd_pcm_channel_area_t *dst_areas;
        const snd_pcm_channel_area_t *src_areas;
 
-       if ((snd_pcm_format_physical_width(dmix->type) % 8) != 0)
+       bits = snd_pcm_format_physical_width(dmix->type);
+       if ((bits % 8) != 0)
                interleaved = 0;
        channels = dmix->channels;
        dst_areas = snd_pcm_mmap_areas(dmix->spcm);
@@ -1167,13 +1168,13 @@ int snd_pcm_direct_check_interleave(snd_pcm_direct_t *dmix, snd_pcm_t *pcm)
                        interleaved = 0;
                        break;
                }
-               if (dst_areas[chn].first != sizeof(signed short) * chn * 8 ||
-                   dst_areas[chn].step != channels * sizeof(signed short) * 8) {
+               if (dst_areas[chn].first != chn * bits ||
+                   dst_areas[chn].step != channels * bits) {
                        interleaved = 0;
                        break;
                }
-               if (src_areas[chn].first != sizeof(signed short) * chn * 8 ||
-                   src_areas[chn].step != channels * sizeof(signed short) * 8) {
+               if (src_areas[chn].first != chn * bits ||
+                   src_areas[chn].step != channels * bits) {
                        interleaved = 0;
                        break;
                }