aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-09 20:53:46 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-09 20:53:46 +0000
commite0d2234cfa22c69e685b5ae58192227d35ea8d3b (patch)
treeba8ab3c998b01e2b48d2ac1992f4dff50cab0e59 /res/res_musiconhold.c
parent087e5058aad53ac4f067a24a622e84e4b949fa24 (diff)
(closes issue #10123)
Reported by: blitzrage Patches submitted by: juggie, qwell, me Tested by: blitzrage When trying to find a music on hold class to use, try all of the options, instead of only the first one that is set. Also, change the MusicOnHold applications to not hang up on the channel when a class can not be found. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@74162 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 57c56e568..cd1ad2ea0 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -573,7 +573,7 @@ static int moh0_exec(struct ast_channel *chan, void *data)
{
if (ast_moh_start(chan, data, NULL)) {
ast_log(LOG_WARNING, "Unable to start music on hold (class '%s') on channel %s\n", (char *)data, chan->name);
- return -1;
+ return 0;
}
while (!ast_safe_sleep(chan, 10000));
ast_moh_stop(chan);
@@ -589,7 +589,7 @@ static int moh1_exec(struct ast_channel *chan, void *data)
}
if (ast_moh_start(chan, NULL, NULL)) {
ast_log(LOG_WARNING, "Unable to start music on hold for %d seconds on channel %s\n", atoi(data), chan->name);
- return -1;
+ return 0;
}
res = ast_safe_sleep(chan, atoi(data) * 1000);
ast_moh_stop(chan);
@@ -634,6 +634,9 @@ static struct mohclass *get_mohbyname(const char *name)
break;
}
+ if (!moh)
+ ast_log(LOG_WARNING, "Music on Hold class '%s' not found\n", name);
+
return moh;
}
@@ -917,7 +920,6 @@ static void local_ast_moh_cleanup(struct ast_channel *chan)
static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
{
struct mohclass *mohclass;
- const char *class;
/* The following is the order of preference for which class to use:
* 1) The channels explicitly set musicclass, which should *only* be
@@ -930,23 +932,19 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
* option.
* 4) The default class.
*/
- if (!ast_strlen_zero(chan->musicclass))
- class = chan->musicclass;
- else if (!ast_strlen_zero(mclass))
- class = mclass;
- else if (!ast_strlen_zero(interpclass))
- class = interpclass;
- else
- class = "default";
-
AST_LIST_LOCK(&mohclasses);
- mohclass = get_mohbyname(class);
+ if (!ast_strlen_zero(chan->musicclass))
+ mohclass = get_mohbyname(chan->musicclass);
+ if (!mohclass && !ast_strlen_zero(mclass))
+ mohclass = get_mohbyname(mclass);
+ if (!mohclass && !ast_strlen_zero(interpclass))
+ mohclass = get_mohbyname(interpclass);
+ if (!mohclass)
+ mohclass = get_mohbyname("default");
AST_LIST_UNLOCK(&mohclasses);
- if (!mohclass) {
- ast_log(LOG_WARNING, "No class: %s\n", class);
+ if (!mohclass)
return -1;
- }
ast_set_flag(chan, AST_FLAG_MOH);
if (mohclass->total_files) {