Fixed silence_64 and added support for 24-bit samples to area_silence

This commit is contained in:
Jaroslav Kysela 2002-07-21 08:19:40 +00:00
parent fe58dd62eb
commit 2db6b18b39
3 changed files with 44 additions and 20 deletions

View file

@ -395,6 +395,18 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
return 0x0000800000008000ULL;
case SNDRV_PCM_FORMAT_U32_BE:
return 0x0000008000000080ULL;
case SNDRV_PCM_FORMAT_U24_3LE:
return 0x0000800000800000ULL;
case SNDRV_PCM_FORMAT_U24_3BE:
return 0x0080000080000080ULL;
case SNDRV_PCM_FORMAT_U20_3LE:
return 0x0000080000080000ULL;
case SNDRV_PCM_FORMAT_U20_3BE:
return 0x0008000008000008ULL;
case SNDRV_PCM_FORMAT_U18_3LE:
return 0x0000020000020000ULL;
case SNDRV_PCM_FORMAT_U18_3BE:
return 0x0002000002000002ULL;
#else
case SNDRV_PCM_FORMAT_U16_LE:
return 0x0080008000800080ULL;
@ -408,27 +420,30 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
return 0x0080000000800000ULL;
case SNDRV_PCM_FORMAT_U32_BE:
return 0x8000000080000000ULL;
#endif
case SNDRV_PCM_FORMAT_U24_3LE:
return 0x0080000080000080ULL;
case SNDRV_PCM_FORMAT_U24_3BE:
return 0x0000800000800000ULL;
case SNDRV_PCM_FORMAT_U20_3LE:
return 0x0008000008000008ULL;
case SNDRV_PCM_FORMAT_U20_3BE:
return 0x0000080000080000ULL;
case SNDRV_PCM_FORMAT_U18_3LE:
return 0x0002000002000002ULL;
case SNDRV_PCM_FORMAT_U18_3BE:
return 0x0000020000020000ULL;
#endif
case SNDRV_PCM_FORMAT_FLOAT_LE:
{
union {
float f;
u_int32_t i;
float f[2];
u_int64_t i;
} u;
u.f = 0.0;
u.f[0] = u.f[1] = 0.0;
#ifdef SNDRV_LITTLE_ENDIAN
return u.i;
#else
return bswap_32(u.i);
return bswap_64(u.i);
#endif
}
case SNDRV_PCM_FORMAT_FLOAT64_LE:
@ -447,12 +462,12 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
case SNDRV_PCM_FORMAT_FLOAT_BE:
{
union {
float f;
u_int32_t i;
float f[2];
u_int64_t i;
} u;
u.f = 0.0;
u.f[0] = u.f[1] = 0.0;
#ifdef SNDRV_LITTLE_ENDIAN
return bswap_32(u.i);
return bswap_64(u.i);
#else
return u.i;
#endif
@ -562,11 +577,16 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
if (! silence)
memset(data, 0, samples * 3);
else {
/* FIXME: rewrite in the more better way.. */
int i;
while (samples-- > 0) {
for (i = 0; i < 3; i++)
*((u_int8_t *)data)++ = silence >> (i * 8);
#ifdef SNDRV_LITTLE_ENDIAN
*((u_int8_t *)data)++ = silence >> 0;
*((u_int8_t *)data)++ = silence >> 8;
*((u_int8_t *)data)++ = silence >> 16;
#else
*((u_int8_t *)data)++ = silence >> 16;
*((u_int8_t *)data)++ = silence >> 8;
*((u_int8_t *)data)++ = silence >> 0;
#endif
}
}
}