mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pw-cat: improve sndfile file format debug info
Print the endianness, container name and the sample format nicely instead of dumping the hex values.
This commit is contained in:
parent
dda60fb374
commit
b238c9d7a1
1 changed files with 30 additions and 4 deletions
|
|
@ -1436,6 +1436,21 @@ static int setup_encodedfile(struct data *data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char *endianness_to_name(int format)
|
||||||
|
{
|
||||||
|
switch (format & SF_FORMAT_ENDMASK) {
|
||||||
|
case SF_ENDIAN_FILE:
|
||||||
|
return "Default Endian";
|
||||||
|
case SF_ENDIAN_LITTLE:
|
||||||
|
return "Little Endian";
|
||||||
|
case SF_ENDIAN_BIG:
|
||||||
|
return "Big Endian";
|
||||||
|
case SF_ENDIAN_CPU:
|
||||||
|
return "CPU Endian";
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
static int setup_sndfile(struct data *data)
|
static int setup_sndfile(struct data *data)
|
||||||
{
|
{
|
||||||
const struct format_info *fi = NULL;
|
const struct format_info *fi = NULL;
|
||||||
|
|
@ -1473,9 +1488,21 @@ static int setup_sndfile(struct data *data)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->verbose)
|
if (data->verbose) {
|
||||||
fprintf(stderr, "sndfile: opened file \"%s\" format %08x channels:%d rate:%d\n",
|
SF_FORMAT_INFO ti, sti;
|
||||||
data->filename, info.format, info.channels, info.samplerate);
|
spa_zero(ti);
|
||||||
|
ti.format = info.format & SF_FORMAT_TYPEMASK;
|
||||||
|
if (sf_command(NULL, SFC_GET_FORMAT_INFO, &ti, sizeof(ti)) != 0)
|
||||||
|
ti.name = "unknown";
|
||||||
|
spa_zero(sti);
|
||||||
|
sti.format = info.format & SF_FORMAT_SUBMASK;
|
||||||
|
if (sf_command(NULL, SFC_GET_FORMAT_INFO, &sti, sizeof(sti)) != 0)
|
||||||
|
sti.name = "unknown";
|
||||||
|
|
||||||
|
fprintf(stderr, "sndfile: opened file \"%s\" format \"%s %s %s\" channels:%d rate:%d\n",
|
||||||
|
data->filename, endianness_to_name(info.format),
|
||||||
|
ti.name, sti.name, info.channels, info.samplerate);
|
||||||
|
}
|
||||||
if (data->channels > 0 && info.channels != (int)data->channels) {
|
if (data->channels > 0 && info.channels != (int)data->channels) {
|
||||||
fprintf(stderr, "sndfile: given channels (%u) don't match file channels (%d)\n",
|
fprintf(stderr, "sndfile: given channels (%u) don't match file channels (%d)\n",
|
||||||
data->channels, info.channels);
|
data->channels, info.channels);
|
||||||
|
|
@ -1511,7 +1538,6 @@ static int setup_sndfile(struct data *data)
|
||||||
/* try native format first, else decode to float */
|
/* try native format first, else decode to float */
|
||||||
if ((fi = format_info_by_sf_format(info.format)) == NULL)
|
if ((fi = format_info_by_sf_format(info.format)) == NULL)
|
||||||
fi = format_info_by_sf_format(SF_FORMAT_FLOAT);
|
fi = format_info_by_sf_format(SF_FORMAT_FLOAT);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (fi == NULL)
|
if (fi == NULL)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue