mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-18 08:56:42 -05:00
Fixed silence_64 and added support for 24-bit samples to area_silence
This commit is contained in:
parent
fe58dd62eb
commit
2db6b18b39
3 changed files with 44 additions and 20 deletions
|
|
@ -1906,6 +1906,17 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 24:
|
||||||
|
#ifdef SNDRV_LITTLE_ENDIAN
|
||||||
|
*(dst + 0) = silence >> 0;
|
||||||
|
*(dst + 1) = silence >> 8;
|
||||||
|
*(dst + 2) = silence >> 16;
|
||||||
|
#else
|
||||||
|
*(dst + 2) = silence >> 0;
|
||||||
|
*(dst + 1) = silence >> 8;
|
||||||
|
*(dst + 0) = silence >> 16;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case 32: {
|
case 32: {
|
||||||
u_int32_t sil = silence;
|
u_int32_t sil = silence;
|
||||||
while (samples-- > 0) {
|
while (samples-- > 0) {
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,18 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
|
||||||
return 0x0000800000008000ULL;
|
return 0x0000800000008000ULL;
|
||||||
case SNDRV_PCM_FORMAT_U32_BE:
|
case SNDRV_PCM_FORMAT_U32_BE:
|
||||||
return 0x0000008000000080ULL;
|
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
|
#else
|
||||||
case SNDRV_PCM_FORMAT_U16_LE:
|
case SNDRV_PCM_FORMAT_U16_LE:
|
||||||
return 0x0080008000800080ULL;
|
return 0x0080008000800080ULL;
|
||||||
|
|
@ -408,27 +420,30 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
|
||||||
return 0x0080000000800000ULL;
|
return 0x0080000000800000ULL;
|
||||||
case SNDRV_PCM_FORMAT_U32_BE:
|
case SNDRV_PCM_FORMAT_U32_BE:
|
||||||
return 0x8000000080000000ULL;
|
return 0x8000000080000000ULL;
|
||||||
#endif
|
|
||||||
case SNDRV_PCM_FORMAT_U24_3LE:
|
case SNDRV_PCM_FORMAT_U24_3LE:
|
||||||
|
return 0x0080000080000080ULL;
|
||||||
case SNDRV_PCM_FORMAT_U24_3BE:
|
case SNDRV_PCM_FORMAT_U24_3BE:
|
||||||
return 0x0000800000800000ULL;
|
return 0x0000800000800000ULL;
|
||||||
case SNDRV_PCM_FORMAT_U20_3LE:
|
case SNDRV_PCM_FORMAT_U20_3LE:
|
||||||
|
return 0x0008000008000008ULL;
|
||||||
case SNDRV_PCM_FORMAT_U20_3BE:
|
case SNDRV_PCM_FORMAT_U20_3BE:
|
||||||
return 0x0000080000080000ULL;
|
return 0x0000080000080000ULL;
|
||||||
case SNDRV_PCM_FORMAT_U18_3LE:
|
case SNDRV_PCM_FORMAT_U18_3LE:
|
||||||
|
return 0x0002000002000002ULL;
|
||||||
case SNDRV_PCM_FORMAT_U18_3BE:
|
case SNDRV_PCM_FORMAT_U18_3BE:
|
||||||
return 0x0000020000020000ULL;
|
return 0x0000020000020000ULL;
|
||||||
|
#endif
|
||||||
case SNDRV_PCM_FORMAT_FLOAT_LE:
|
case SNDRV_PCM_FORMAT_FLOAT_LE:
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
float f;
|
float f[2];
|
||||||
u_int32_t i;
|
u_int64_t i;
|
||||||
} u;
|
} u;
|
||||||
u.f = 0.0;
|
u.f[0] = u.f[1] = 0.0;
|
||||||
#ifdef SNDRV_LITTLE_ENDIAN
|
#ifdef SNDRV_LITTLE_ENDIAN
|
||||||
return u.i;
|
return u.i;
|
||||||
#else
|
#else
|
||||||
return bswap_32(u.i);
|
return bswap_64(u.i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
case SNDRV_PCM_FORMAT_FLOAT64_LE:
|
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:
|
case SNDRV_PCM_FORMAT_FLOAT_BE:
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
float f;
|
float f[2];
|
||||||
u_int32_t i;
|
u_int64_t i;
|
||||||
} u;
|
} u;
|
||||||
u.f = 0.0;
|
u.f[0] = u.f[1] = 0.0;
|
||||||
#ifdef SNDRV_LITTLE_ENDIAN
|
#ifdef SNDRV_LITTLE_ENDIAN
|
||||||
return bswap_32(u.i);
|
return bswap_64(u.i);
|
||||||
#else
|
#else
|
||||||
return u.i;
|
return u.i;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -562,11 +577,16 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
|
||||||
if (! silence)
|
if (! silence)
|
||||||
memset(data, 0, samples * 3);
|
memset(data, 0, samples * 3);
|
||||||
else {
|
else {
|
||||||
/* FIXME: rewrite in the more better way.. */
|
|
||||||
int i;
|
|
||||||
while (samples-- > 0) {
|
while (samples-- > 0) {
|
||||||
for (i = 0; i < 3; i++)
|
#ifdef SNDRV_LITTLE_ENDIAN
|
||||||
*((u_int8_t *)data)++ = silence >> (i * 8);
|
*((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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,6 @@
|
||||||
|
|
||||||
#define as_u8c(ptr) (*(const u_int8_t*)(ptr))
|
#define as_u8c(ptr) (*(const u_int8_t*)(ptr))
|
||||||
#define as_u16c(ptr) (*(const u_int16_t*)(ptr))
|
#define as_u16c(ptr) (*(const u_int16_t*)(ptr))
|
||||||
#ifdef SND_LITTLE_ENDIAN
|
|
||||||
#define as_u24c(ptr) (u_int32_t)(as_u8(ptr) | as_u8(((char *)ptr) + 1) << 8 | as_u8(((char *)ptr + 2) << 16)
|
|
||||||
#elif defined(SND_BIG_ENDIAN)
|
|
||||||
#define as_u24c(ptr) (u_int32_t)(as_u8(ptr) << 16 | as_u8(((char *)ptr) + 1) << 8 | as_u8(((char *)ptr + 2))
|
|
||||||
#else
|
|
||||||
#error "Wrong endian..."
|
|
||||||
#endif
|
|
||||||
#define as_u32c(ptr) (*(const u_int32_t*)(ptr))
|
#define as_u32c(ptr) (*(const u_int32_t*)(ptr))
|
||||||
#define as_u64c(ptr) (*(const u_int64_t*)(ptr))
|
#define as_u64c(ptr) (*(const u_int64_t*)(ptr))
|
||||||
#define as_s8c(ptr) (*(const int8_t*)(ptr))
|
#define as_s8c(ptr) (*(const int8_t*)(ptr))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue