? doc/api
Index: configs/musiconhold.conf.sample
===================================================================
RCS file: /usr/cvsroot/asterisk/configs/musiconhold.conf.sample,v
retrieving revision 1.2
diff -u -r1.2 musiconhold.conf.sample
--- configs/musiconhold.conf.sample	29 Apr 2004 03:36:46 -0000	1.2
+++ configs/musiconhold.conf.sample	13 Jul 2004 01:10:47 -0000
@@ -7,3 +7,5 @@
 ;random => quietmp3:/var/lib/asterisk/mohmp3,-z
 ;unbuffered => mp3nb:/var/lib/asterisk/mohmp3
 ;quietunbuf => quietmp3nb:/var/lib/asterisk/mohmp3
+; Note that the customcommand mode cannot handle escaped parameters (specifically embedded spaces)
+;manual => customcommand:/var/lib/asterisk/mohmp3,/usr/bin/mpg123 -q -r 8000 -f 8192 -b 2048 --mono -s
Index: res/res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.34
diff -u -r1.34 res_musiconhold.c
--- res/res_musiconhold.c	2 Jul 2004 23:11:14 -0000	1.34
+++ res/res_musiconhold.c	13 Jul 2004 01:10:48 -0000
@@ -79,6 +79,7 @@
 	int pid;		/* PID of mpg123 */
 	int quiet;
 	int single;
+	int customcommand;
 	pthread_t thread;
 	struct mohdata *members;
 	/* Source of audio */
@@ -119,34 +120,49 @@
 		ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir);
 		return -1;
  	}
-	argv[argc++] = "mpg123";
-	argv[argc++] = "-q";
-	argv[argc++] = "-s";
-	argv[argc++] = "--mono";
-	argv[argc++] = "-r";
-	argv[argc++] = "8000";
-
-	if (!class->single) {
-		argv[argc++] = "-b";
-		argv[argc++] = "2048";
-	}
-
-	argv[argc++] = "-f";
-	
-	if (class->quiet) {
-		argv[argc++] = "4096";
-	} else
-		argv[argc++] = "8192";
-
-	/* Look for extra arguments and add them to the list */
-	strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
-	argptr = xargs;
-	while(argptr && !ast_strlen_zero(argptr)) {
-		argv[argc++] = argptr;
-		argptr = strchr(argptr, ',');
-		if (argptr) {
-			*argptr = '\0';
-			argptr++;
+
+	if (!class->customcommand) {
+		argv[argc++] = "mpg123";
+		argv[argc++] = "-q";
+		argv[argc++] = "-s";
+		argv[argc++] = "--mono";
+		argv[argc++] = "-r";
+		argv[argc++] = "8000";
+		
+		if (!class->single) {
+			argv[argc++] = "-b";
+			argv[argc++] = "2048";
+		}
+
+		argv[argc++] = "-f";
+
+		if (class->quiet)
+			argv[argc++] = "4096";
+		else
+			argv[argc++] = "8192";
+
+		/* Look for extra arguments and add them to the list */
+		strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
+		argptr = xargs;
+		while(argptr && !ast_strlen_zero(argptr)) {
+			argv[argc++] = argptr;
+			argptr = strchr(argptr, ',');
+			if (argptr) {
+				*argptr = '\0';
+				argptr++;
+			}
+		}
+	} else {
+		/* Format arguments for argv vector */
+		strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
+		argptr = xargs;
+		while(argptr && !ast_strlen_zero(argptr)) {
+			argv[argc++] = argptr;
+			argptr = strchr(argptr, ' ');
+			if (argptr) {
+				*argptr = '\0';
+				argptr++;
+			}
 		}
 	}
 
@@ -195,12 +211,16 @@
 			close(x);
 		/* Child */
 		chdir(class->dir);
-		/* Default install is /usr/local/bin */
-		execv(LOCAL_MPG_123, argv);
-		/* Many places have it in /usr/bin */
-		execv(MPG_123, argv);
-		/* Check PATH as a last-ditch effort */
-		execvp("mpg123", argv);
+		if(class->customcommand) {
+			execv(argv[0], argv);
+		} else {
+			/* Default install is /usr/local/bin */
+			execv(LOCAL_MPG_123, argv);
+			/* Many places have it in /usr/bin */
+			execv(MPG_123, argv);
+			/* Check PATH as a last-ditch effort */
+			execvp("mpg123", argv);
+		}
 		ast_log(LOG_WARNING, "Exec failed: %s\n", strerror(errno));
 		close(fds[1]);
 		exit(1);
@@ -506,7 +526,9 @@
 	strncpy(moh->class, classname, sizeof(moh->class) - 1);
 	if (miscargs)
 		strncpy(moh->miscargs, miscargs, sizeof(moh->miscargs) - 1);
-	if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb") || !strcasecmp(mode, "httpmp3")) {
+	if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb") || !strcasecmp(mode, "httpmp3") || !strcasecmp(mode, "customcommand")) {
+		if (!strcasecmp(mode, "customcommand"))
+			moh->customcommand = 1;
 		if (!strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3nb"))
 			moh->single = 1;
 		if (!strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb"))
