[asterisk-commits] mmichelson: branch 1.6.0 r209198 - in /branches/1.6.0: ./ res/res_musiconhold.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 27 15:16:32 CDT 2009


Author: mmichelson
Date: Mon Jul 27 15:16:28 2009
New Revision: 209198

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=209198
Log:
Merged revisions 209197 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r209197 | mmichelson | 2009-07-27 15:11:42 -0500 (Mon, 27 Jul 2009) | 9 lines
  
  Honor channel's music class when using realtime music on hold.
  
  (closes issue #15051)
  Reported by: alexh
  Patches:
        15051.patch uploaded by mmichelson (license 60)
  Tested by: alexh
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/res/res_musiconhold.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/res/res_musiconhold.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.0/res/res_musiconhold.c?view=diff&rev=209198&r1=209197&r2=209198
==============================================================================
--- branches/1.6.0/res/res_musiconhold.c (original)
+++ branches/1.6.0/res/res_musiconhold.c Mon Jul 27 15:16:28 2009
@@ -1155,7 +1155,9 @@
 {
 	struct mohclass *mohclass = NULL;
 	struct moh_files_state *state = chan->music_state;
+	struct ast_variable *var = NULL;
 	int res;
+	int realtime_possible = ast_check_realtime("musiconhold");
 
 	/* The following is the order of preference for which class to use:
 	 * 1) The channels explicitly set musicclass, which should *only* be
@@ -1170,28 +1172,37 @@
 	 */
 	if (!ast_strlen_zero(chan->musicclass)) {
 		mohclass = get_mohbyname(chan->musicclass, 1);
-	}
-	if (!mohclass && !ast_strlen_zero(mclass)) {
+		if (!mohclass && realtime_possible) {
+			var = ast_load_realtime("musiconhold", "name", chan->musicclass, NULL);
+		}
+	}
+	if (!mohclass && !var && !ast_strlen_zero(mclass)) {
 		mohclass = get_mohbyname(mclass, 1);
-	}
-	if (!mohclass && !ast_strlen_zero(interpclass)) {
+		if (!mohclass && realtime_possible) {
+			var = ast_load_realtime("musiconhold", "name", mclass, NULL);
+		}
+	}
+	if (!mohclass && !var && !ast_strlen_zero(interpclass)) {
 		mohclass = get_mohbyname(interpclass, 1);
-	}
-
-	/* If no moh class found in memory, then check RT */
-	if (!mohclass && ast_check_realtime("musiconhold")) {
-		struct ast_variable *var = NULL, *tmp = NULL;
-
-		if (!ast_strlen_zero(chan->musicclass)) {
-			var = ast_load_realtime("musiconhold", "name", chan->musicclass, NULL);
-		}
-		if (!var && !ast_strlen_zero(mclass))
-			var = ast_load_realtime("musiconhold", "name", mclass, NULL);
-		if (!var && !ast_strlen_zero(interpclass))
+		if (!mohclass && realtime_possible) {
 			var = ast_load_realtime("musiconhold", "name", interpclass, NULL);
-		if (!var)
+		}
+	}
+
+	if (!mohclass && !var) {
+		mohclass = get_mohbyname("default", 1);
+		if (!mohclass && realtime_possible) {
 			var = ast_load_realtime("musiconhold", "name", "default", NULL);
-		if (var && (mohclass = moh_class_malloc())) {
+		}
+	}
+
+	/* If no moh class found in memory, then check RT. Note that the logic used
+	 * above guarantees that if var is non-NULL, then mohclass must be NULL.
+	 */
+	if (var) {
+		struct ast_variable *tmp = NULL;
+
+		if ((mohclass = moh_class_malloc())) {
 			mohclass->realtime = 1;
 			for (tmp = var; tmp; tmp = tmp->next) {
 				if (!strcasecmp(tmp->name, "name"))
@@ -1321,13 +1332,9 @@
 					return -1;
 				}
 			}
-		} else if (var) {
+		} else {
 			ast_variables_destroy(var);
 		}
-	}
-
-	if (!mohclass) {
-		mohclass = get_mohbyname("default", 1);
 	}
 
 	if (!mohclass) {




More information about the asterisk-commits mailing list