mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Added snd_pcm_build_linear_format
This commit is contained in:
parent
244d345fda
commit
3696e16613
2 changed files with 44 additions and 3 deletions
|
|
@ -56,6 +56,7 @@ int snd_pcm_format_linear(int format);
|
||||||
int snd_pcm_format_little_endian(int format);
|
int snd_pcm_format_little_endian(int format);
|
||||||
int snd_pcm_format_big_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_build_linear_format(int width, int unsignd, int big_endian);
|
||||||
ssize_t snd_pcm_format_size(int format, size_t samples);
|
ssize_t snd_pcm_format_size(int format, size_t samples);
|
||||||
const char *snd_pcm_get_format_name(int format);
|
const char *snd_pcm_get_format_name(int format);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,9 @@ int snd_pcm_format_big_endian(int format)
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = snd_pcm_format_little_endian(format);
|
val = snd_pcm_format_little_endian(format);
|
||||||
if (val >= 0)
|
if (val < 0)
|
||||||
val ^= 1;
|
|
||||||
return val;
|
return val;
|
||||||
|
return !val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_pcm_format_width(int format)
|
int snd_pcm_format_width(int format)
|
||||||
|
|
@ -227,3 +227,43 @@ const char *snd_pcm_get_format_name(int format)
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
return formats[format];
|
return formats[format];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int linear_formats[4][2][2] = {
|
||||||
|
SND_PCM_SFMT_S8,
|
||||||
|
SND_PCM_SFMT_U8,
|
||||||
|
SND_PCM_SFMT_S8,
|
||||||
|
SND_PCM_SFMT_U8,
|
||||||
|
SND_PCM_SFMT_S16_LE,
|
||||||
|
SND_PCM_SFMT_S16_BE,
|
||||||
|
SND_PCM_SFMT_U16_LE,
|
||||||
|
SND_PCM_SFMT_U16_BE,
|
||||||
|
SND_PCM_SFMT_S24_LE,
|
||||||
|
SND_PCM_SFMT_S24_BE,
|
||||||
|
SND_PCM_SFMT_U24_LE,
|
||||||
|
SND_PCM_SFMT_U24_BE,
|
||||||
|
SND_PCM_SFMT_S32_LE,
|
||||||
|
SND_PCM_SFMT_S32_BE,
|
||||||
|
SND_PCM_SFMT_U32_LE,
|
||||||
|
SND_PCM_SFMT_U32_BE
|
||||||
|
};
|
||||||
|
|
||||||
|
int snd_pcm_build_linear_format(int width, int unsignd, int big_endian)
|
||||||
|
{
|
||||||
|
switch (width) {
|
||||||
|
case 8:
|
||||||
|
width = 0;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
width = 1;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
width = 2;
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
width = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return linear_formats[width][!!unsignd][!!big_endian];
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue