diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-03-24 21:13:57 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-03-24 21:13:57 -0500 |
commit | 36d016b1abb6707bfde821ac2407933a447f3d13 (patch) | |
tree | c9eb41e063c45ef074eaaf67f56c23ec7bc28053 | |
parent | 8271a06dde1e6e7adfabf0f06d45442dee925d5a (diff) | |
parent | ff3eebf454301ffca414c652415c3fcaaecf134d (diff) |
Merge "musiconhold: Only warn if music class is not found in memory and database." into 13
-rw-r--r-- | res/res_musiconhold.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 669fb9bc9..6f5182072 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1349,6 +1349,18 @@ static struct mohclass *_moh_class_malloc(const char *file, int line, const char return class; } +static struct ast_variable *load_realtime_musiconhold(const char *name) +{ + struct ast_variable *var = ast_load_realtime("musiconhold", "name", name, SENTINEL); + if (!var) { + ast_log(LOG_WARNING, + "Music on Hold class '%s' not found in memory/database. " + "Verify your configuration.\n", + name); + } + return var; +} + static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass) { struct mohclass *mohclass = NULL; @@ -1356,6 +1368,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con struct ast_variable *var = NULL; int res = 0; int realtime_possible = ast_check_realtime("musiconhold"); + int warn_if_not_in_memory = !realtime_possible; /* The following is the order of preference for which class to use: * 1) The channels explicitly set musicclass, which should *only* be @@ -1369,28 +1382,28 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con * 4) The default class. */ if (!ast_strlen_zero(ast_channel_musicclass(chan))) { - mohclass = get_mohbyname(ast_channel_musicclass(chan), 1, 0); + mohclass = get_mohbyname(ast_channel_musicclass(chan), warn_if_not_in_memory, 0); if (!mohclass && realtime_possible) { - var = ast_load_realtime("musiconhold", "name", ast_channel_musicclass(chan), SENTINEL); + var = load_realtime_musiconhold(ast_channel_musicclass(chan)); } } if (!mohclass && !var && !ast_strlen_zero(mclass)) { - mohclass = get_mohbyname(mclass, 1, 0); + mohclass = get_mohbyname(mclass, warn_if_not_in_memory, 0); if (!mohclass && realtime_possible) { - var = ast_load_realtime("musiconhold", "name", mclass, SENTINEL); + var = load_realtime_musiconhold(mclass); } } if (!mohclass && !var && !ast_strlen_zero(interpclass)) { - mohclass = get_mohbyname(interpclass, 1, 0); + mohclass = get_mohbyname(interpclass, warn_if_not_in_memory, 0); if (!mohclass && realtime_possible) { - var = ast_load_realtime("musiconhold", "name", interpclass, SENTINEL); + var = load_realtime_musiconhold(interpclass); } } if (!mohclass && !var) { - mohclass = get_mohbyname("default", 1, 0); + mohclass = get_mohbyname("default", warn_if_not_in_memory, 0); if (!mohclass && realtime_possible) { - var = ast_load_realtime("musiconhold", "name", "default", SENTINEL); + var = load_realtime_musiconhold("default"); } } |