]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
file.c: missing "custom" sound files should not generate warning logs
authorAllan Nathanson <42244061+Allan-N@users.noreply.github.com>
Tue, 18 Mar 2025 23:54:48 +0000 (19:54 -0400)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 1 May 2025 12:41:16 +0000 (12:41 +0000)
With `sounds_search_custom_dir = yes` we first look to see if a sound file
is present in the "custom" sound directory before looking in the standard
sound directories.  We should not be issuing a WARNING log message if a
sound cannot be found in the "custom" directory.

Resolves: https://github.com/asterisk/asterisk/issues/1170
(cherry picked from commit f24729a48d9a63b5fa4b2966b92551c16900f1a8)

main/file.c

index 0f29ca82db2d6922a7fd4994ebb44fdf1386042f..039e33b19aa65d0fadb5492f5bb87f76d25dfce5 100644 (file)
@@ -787,13 +787,8 @@ static int fileexists_core(const char *filename, const char *fmt, const char *pr
        return 0;
 }
 
-struct ast_filestream *ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang)
-{
-       return ast_openstream_full(chan, filename, preflang, 0);
-}
-
-struct ast_filestream *ast_openstream_full(struct ast_channel *chan,
-       const char *filename, const char *preflang, int asis)
+static struct ast_filestream *openstream_internal(struct ast_channel *chan,
+       const char *filename, const char *preflang, int asis, int quiet)
 {
        /*
         * Use fileexists_core() to find a file in a compatible
@@ -822,7 +817,9 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan,
        if (!fileexists_core(filename, NULL, preflang, buf, buflen, file_fmt_cap) ||
                !ast_format_cap_has_type(file_fmt_cap, AST_MEDIA_TYPE_AUDIO)) {
 
-               ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
+               if (!quiet) {
+                       ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
+               }
                ao2_ref(file_fmt_cap, -1);
                return NULL;
        }
@@ -845,6 +842,17 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan,
        return NULL;
 }
 
+struct ast_filestream *ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang)
+{
+       return openstream_internal(chan, filename, preflang, 0, 0);
+}
+
+struct ast_filestream *ast_openstream_full(struct ast_channel *chan,
+       const char *filename, const char *preflang, int asis)
+{
+       return openstream_internal(chan, filename, preflang, asis, 0);
+}
+
 struct ast_filestream *ast_openvstream(struct ast_channel *chan,
        const char *filename, const char *preflang)
 {
@@ -1307,7 +1315,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename,
        if (ast_opt_sounds_search_custom && !is_absolute_path(filename)) {
                memset(custom_filename, 0, sizeof(custom_filename));
                snprintf(custom_filename, sizeof(custom_filename), "custom/%s", filename);
-               fs = ast_openstream(chan, custom_filename, preflang);
+               fs = openstream_internal(chan, filename, preflang, 0, 1); /* open stream, do not warn for missing files */
                if (fs) {
                        tmp_filename = custom_filename;
                        ast_debug(3, "Found file %s in custom directory\n", filename);