module-filter-chain: give better error when load fails

See #3223
This commit is contained in:
Wim Taymans 2023-05-16 22:33:52 +02:00
parent 318bb0b442
commit ca17672871

View file

@ -686,11 +686,15 @@ static float *read_closest(char **filenames, float gain, int delay, int offset,
int diff = INT_MAX;
uint32_t best = 0, i;
float *samples = NULL;
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])
if (!fs[i]) {
pw_log_error("Can't open file %s: %s", filenames[i],
sf_strerror(fs[i]));
continue;
}
if (labs((long)infos[i].samplerate - (long)*rate) < diff) {
best = i;
@ -698,11 +702,11 @@ static float *read_closest(char **filenames, float gain, int delay, int offset,
pw_log_debug("new closest match: %d", infos[i].samplerate);
}
}
pw_log_info("loading best rate:%u %s", infos[best].samplerate, filenames[best]);
float *samples = read_samples_from_sf(fs[best], infos[best], gain, delay,
offset, length, channel, rate, n_samples);
if (fs[best] != NULL) {
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);
}
for (i = 0; i < MAX_RATES; i++)
if (fs[i])
sf_close(fs[i]);