pw-cat: support u8 format as well

This commit is contained in:
Wim Taymans 2021-06-03 10:05:43 +02:00
parent 8b98d111e1
commit 6971d11901

View file

@ -170,6 +170,8 @@ sf_str_to_fmt(const char *str)
if (spa_streq(str, "s8"))
return SF_FORMAT_PCM_S8;
if (spa_streq(str, "u8"))
return SF_FORMAT_PCM_U8;
if (spa_streq(str, "s16"))
return SF_FORMAT_PCM_16;
if (spa_streq(str, "s24"))
@ -189,6 +191,8 @@ sf_fmt_to_str(int format)
{
int sub_type = (format & SF_FORMAT_SUBMASK);
if (sub_type == SF_FORMAT_PCM_U8)
return "u8";
if (sub_type == SF_FORMAT_PCM_S8)
return "s8";
if (sub_type == SF_FORMAT_PCM_16)
@ -204,7 +208,7 @@ sf_fmt_to_str(int format)
return "(invalid)";
}
#define STR_FMTS "(s8|s16|s32|f32|f64)"
#define STR_FMTS "(u8|s8|s16|s32|f32|f64)"
/* 0 = native, 1 = le, 2 = be */
static inline int
@ -223,6 +227,8 @@ sf_format_to_pw(int format)
return SPA_AUDIO_FORMAT_UNKNOWN;
switch (format & SF_FORMAT_SUBMASK) {
case SF_FORMAT_PCM_U8:
return SPA_AUDIO_FORMAT_U8;
case SF_FORMAT_PCM_S8:
return SPA_AUDIO_FORMAT_S8;
case SF_FORMAT_PCM_16:
@ -256,6 +262,7 @@ sf_format_samplesize(int format)
switch (sub_type) {
case SF_FORMAT_PCM_S8:
case SF_FORMAT_PCM_U8:
return 1;
case SF_FORMAT_PCM_16:
return 2;
@ -270,7 +277,7 @@ sf_format_samplesize(int format)
return -1;
}
static int sf_playback_fill_s8(struct data *d, void *dest, unsigned int n_frames)
static int sf_playback_fill_x8(struct data *d, void *dest, unsigned int n_frames)
{
sf_count_t rn;
@ -321,7 +328,8 @@ sf_fmt_playback_fill_fn(int format)
switch (fmt) {
case SPA_AUDIO_FORMAT_S8:
return sf_playback_fill_s8;
case SPA_AUDIO_FORMAT_U8:
return sf_playback_fill_x8;
case SPA_AUDIO_FORMAT_S16_LE:
case SPA_AUDIO_FORMAT_S16_BE:
/* sndfile check */
@ -351,7 +359,7 @@ sf_fmt_playback_fill_fn(int format)
return NULL;
}
static int sf_record_fill_s8(struct data *d, void *src, unsigned int n_frames)
static int sf_record_fill_x8(struct data *d, void *src, unsigned int n_frames)
{
sf_count_t rn;
@ -402,7 +410,8 @@ sf_fmt_record_fill_fn(int format)
switch (fmt) {
case SPA_AUDIO_FORMAT_S8:
return sf_record_fill_s8;
case SPA_AUDIO_FORMAT_U8:
return sf_record_fill_x8;
case SPA_AUDIO_FORMAT_S16_LE:
case SPA_AUDIO_FORMAT_S16_BE:
/* sndfile check */