[asterisk-commits] russell: branch 1.2 r74165 - /branches/1.2/res/res_musiconhold.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 9 16:00:17 CDT 2007


Author: russell
Date: Mon Jul  9 16:00:17 2007
New Revision: 74165

URL: http://svn.digium.com/view/asterisk?view=rev&rev=74165
Log:
When the specified class isn't found, properly fall back to the channel's music
class or the default.
(issue #10123, reported by blitzrage, patches from juggie, qwell, and me)

Modified:
    branches/1.2/res/res_musiconhold.c

Modified: branches/1.2/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_musiconhold.c?view=diff&rev=74165&r1=74164&r2=74165
==============================================================================
--- branches/1.2/res/res_musiconhold.c (original)
+++ branches/1.2/res/res_musiconhold.c Mon Jul  9 16:00:17 2007
@@ -636,6 +636,7 @@
 			return moh;
 		moh = moh->next;
 	}
+	ast_log(LOG_WARNING, "Music on Hold class '%s' not found\n", name);
 	return NULL;
 }
 
@@ -908,20 +909,19 @@
 
 static int local_ast_moh_start(struct ast_channel *chan, char *class)
 {
-	struct mohclass *mohclass;
-
-	if (ast_strlen_zero(class))
-		class = chan->musicclass;
-	if (ast_strlen_zero(class))
-		class = "default";
+	struct mohclass *mohclass = NULL;
+
 	ast_mutex_lock(&moh_lock);
-	mohclass = get_mohbyname(class);
+	if (!ast_strlen_zero(class))
+		mohclass = get_mohbyname(class);
+	if (!mohclass && !ast_strlen_zero(chan->musicclass))
+		mohclass = get_mohbyname(chan->musicclass);
+	if (!mohclass)
+		mohclass = get_mohbyname("default");
 	ast_mutex_unlock(&moh_lock);
 
-	if (!mohclass) {
-		ast_log(LOG_WARNING, "No class: %s\n", (char *)class);
-		return -1;
-	}
+	if (!mohclass)
+		return -1;
 
 	ast_set_flag(chan, AST_FLAG_MOH);
 	if (mohclass->total_files) {




More information about the asterisk-commits mailing list