LADI
/
spa
1
Fork 0

module-filter-chain: do better error reporting

When we find no valid sample file to read, go through all files and
report why they fail to load. Also display the current working directory
so that we can see where file are loaded from.

See #3223
This commit is contained in:
Wim Taymans 2023-05-17 11:01:26 +02:00
parent 65a5272a9f
commit 135647f193
1 changed files with 13 additions and 5 deletions

View File

@ -690,11 +690,8 @@ static float *read_closest(char **filenames, float gain, int delay, int offset,
for (i = 0; i < MAX_RATES && filenames[i] && filenames[i][0]; i++) {
fs[i] = sf_open(filenames[i], SFM_READ, &infos[i]);
if (!fs[i]) {
pw_log_error("Can't open file %s: %s", filenames[i],
sf_strerror(fs[i]));
if (fs[i] == NULL)
continue;
}
if (labs((long)infos[i].samplerate - (long)*rate) < diff) {
best = i;
@ -706,9 +703,20 @@ static float *read_closest(char **filenames, float gain, int delay, int offset,
pw_log_info("loading best rate:%u %s", infos[best].samplerate, filenames[best]);
samples = read_samples_from_sf(fs[best], infos[best], gain, delay,
offset, length, channel, rate, n_samples);
} else {
char buf[PATH_MAX];
pw_log_error("Can't open any sample file (CWD %s):",
getcwd(buf, sizeof(buf)));
for (i = 0; i < MAX_RATES && filenames[i] && filenames[i][0]; i++) {
fs[i] = sf_open(filenames[i], SFM_READ, &infos[i]);
if (fs[i] == NULL)
pw_log_error(" failed file %s: %s", filenames[i], sf_strerror(fs[i]));
else
pw_log_warn(" unexpectedly opened file %s", filenames[i]);
}
}
for (i = 0; i < MAX_RATES; i++)
if (fs[i])
if (fs[i] != NULL)
sf_close(fs[i]);
return samples;