Index: res/res_musiconhold.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v retrieving revision 1.52 diff -u -r1.52 res_musiconhold.c --- res/res_musiconhold.c 25 Jan 2005 06:10:20 -0000 1.52 +++ res/res_musiconhold.c 2 Mar 2005 23:27:01 -0000 @@ -511,15 +511,45 @@ return NULL; } +static char * ast_next_opt(char *optstr, char delim) { + char *newstr = NULL; + + if((newstr = strchr(optstr, delim))) { + *newstr = '\0'; + newstr++; + } + + return newstr; +} + static int moh0_exec(struct ast_channel *chan, void *data) { - if (ast_moh_start(chan, data)) { - ast_log(LOG_WARNING, "Unable to start music on hold (class '%s') on channel %s\n", (char *)data, chan->name); + char *moh = NULL, *opt = NULL ; + + if ((moh = ast_strdupa(data))) { + opt = ast_next_opt(moh, '|') ; + } + + if (!opt) { + if (ast_moh_start(chan, moh)) { + ast_log(LOG_WARNING, "Unable to start music on hold (class '%s') on channel %s\n", (char *)moh, chan->name); + return -1; + } + + while (!ast_safe_sleep(chan, 10000)); + ast_moh_stop(chan); return -1; } - while (!ast_safe_sleep(chan, 10000)); - ast_moh_stop(chan); - return -1; + else if (strcmp(opt, "start") == 0 && ast_moh_start(chan, moh)) { + ast_log(LOG_WARNING, "Unable to start music on hold (class '%s') on channel %s\n", (char *)moh, chan->name); + return -1; + } + else if (strcmp(opt, "stop") == 0) { + ast_moh_stop(chan); + return 0; + } + + return 0; } static int moh1_exec(struct ast_channel *chan, void *data)