[asterisk-commits] russell: trunk r74163 - in /trunk: ./ res/res_musiconhold.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 9 15:54:34 CDT 2007


Author: russell
Date: Mon Jul  9 15:54:34 2007
New Revision: 74163

URL: http://svn.digium.com/view/asterisk?view=rev&rev=74163
Log:
Merged revisions 74162 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r74162 | russell | 2007-07-09 15:53:46 -0500 (Mon, 09 Jul 2007) | 9 lines

(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.

........

Modified:
    trunk/   (props changed)
    trunk/res/res_musiconhold.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=74163&r1=74162&r2=74163
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Mon Jul  9 15:54:34 2007
@@ -603,7 +603,7 @@
 {
 	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);
@@ -619,7 +619,7 @@
 	}
 	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);
@@ -663,6 +663,9 @@
 		if (!strcasecmp(name, moh->name))
 			break;
 	}
+
+	if (!moh)
+		ast_log(LOG_WARNING, "Music on Hold class '%s' not found\n", name);
 
 	return moh;
 }
@@ -948,7 +951,6 @@
 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
@@ -961,23 +963,19 @@
 	 *    option.
 	 * 4) The default class.
 	 */
+	AST_RWLIST_RDLOCK(&mohclasses);
 	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_RWLIST_RDLOCK(&mohclasses);
-	mohclass = get_mohbyname(class);
+		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_RWLIST_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) {




More information about the asterisk-commits mailing list