--- a/res/res_musiconhold.c 2014-08-25 18:45:40.000000000 +0200 +++ b/res/res_musiconhold.c 2014-08-28 08:18:05.706685774 +0200 @@ -149,8 +149,9 @@ #define MOH_RANDOMIZE (1 << 3) #define MOH_SORTALPHA (1 << 4) -#define MOH_CACHERTCLASSES (1 << 5) /*!< Should we use a separate instance of MOH for each user or not */ -#define MOH_ANNOUNCEMENT (1 << 6) /*!< Do we play announcement files between songs on this channel? */ +#define MOH_CACHERTCLASSES (1 << 5) /*!< Should we use a separate instance of MOH for each user or not */ +#define MOH_ANNOUNCEMENT (1 << 6) /*!< Do we play announcement files between songs on this channel? */ +#define MOH_APPOVERRIDECHANNEL (1 << 7) /*!< Should queue moh override channel moh */ /* Custom astobj2 flag */ #define MOH_NOTDELETED (1 << 30) /*!< Find only records that aren't deleted? */ @@ -1360,15 +1361,18 @@ /* The following is the order of preference for which class to use: * 1) The channels explicitly set musicclass, which should *only* be * set by a call to Set(CHANNEL(musicclass)=whatever) in the dialplan. + * Unless appoverridechannel in musiconhold.conf is true * 2) The mclass argument. If a channel is calling ast_moh_start() as the * result of receiving a HOLD control frame, this should be the * payload that came with the frame. - * 3) The interpclass argument. This would be from the mohinterpret + * 3) The channels explicitly set musicclass, which should *only* be + * set by a call to Set(CHANNEL(musicclass)=whatever) in the dialplan. + * 4) The interpclass argument. This would be from the mohinterpret * option from channel drivers. This is the same as the old musicclass * option. - * 4) The default class. + * 5) The default class. */ - if (!ast_strlen_zero(ast_channel_musicclass(chan))) { + if (!ast_test_flag(global_flags, MOH_APPOVERRIDECHANNEL) && !ast_strlen_zero(chan->musicclass)) { mohclass = get_mohbyname(ast_channel_musicclass(chan), 1, 0); if (!mohclass && realtime_possible) { var = ast_load_realtime("musiconhold", "name", ast_channel_musicclass(chan), SENTINEL); @@ -1380,6 +1384,12 @@ var = ast_load_realtime("musiconhold", "name", mclass, SENTINEL); } } + if (!mohclass && !var && !ast_strlen_zero(chan->musicclass)) { + mohclass = get_mohbyname(chan->musicclass, 1, 0); + if (!mohclass && realtime_possible) { + var = ast_load_realtime("musiconhold", "name", chan->musicclass, SENTINEL); + } + } if (!mohclass && !var && !ast_strlen_zero(interpclass)) { mohclass = get_mohbyname(interpclass, 1, 0); if (!mohclass && realtime_possible) { @@ -1717,6 +1727,8 @@ for (var = ast_variable_browse(cfg, cat); var; var = var->next) { if (!strcasecmp(var->name, "cachertclasses")) { ast_set2_flag(global_flags, ast_true(var->value), MOH_CACHERTCLASSES); + } else if (!strcasecmp(var->name, "appoverridechannel")) { + ast_set2_flag(global_flags, ast_true(var->value), MOH_APPOVERRIDECHANNEL); } else { ast_log(LOG_WARNING, "Unknown option '%s' in [general] section of musiconhold.conf\n", var->name); } --- a/configs/samples/musiconhold.conf.sample 2014-07-17 23:17:28.000000000 +0200 +++ b/configs/samples/musiconhold.conf.sample 2014-08-28 08:14:39.326680869 +0200 @@ -2,9 +2,12 @@ ; Music on Hold -- Sample Configuration ; [general] -;cachertclasses=yes ; use 1 instance of moh class for all users who are using it, - ; decrease consumable cpu cycles and memory - ; disabled by default +;cachertclasses=yes ; use 1 instance of moh class for all users who are using it, + ; decrease consumable cpu cycles and memory + ; disabled by default + +;appoverridechannel=no ; Do applications MOH take precedence over channel musicclass + ; Channels musicclass is used by default ; valid mode options: