From 135647f193156f0651e99063b0c18151a7bd3177 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 17 May 2023 11:01:26 +0200 Subject: [PATCH] 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 --- .../module-filter-chain/builtin_plugin.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/module-filter-chain/builtin_plugin.c b/src/modules/module-filter-chain/builtin_plugin.c index a0e27e568..194d3e239 100644 --- a/src/modules/module-filter-chain/builtin_plugin.c +++ b/src/modules/module-filter-chain/builtin_plugin.c @@ -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;