[Asterisk-cvs] asterisk/apps app_dial.c,1.75,1.76

markster at lists.digium.com markster at lists.digium.com
Mon Jun 21 14:42:40 CDT 2004


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv14295/apps

Modified Files:
	app_dial.c 
Log Message:
Don't stop moh until after announcement finishes (bug #789)


Index: app_dial.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- app_dial.c	21 Jun 2004 13:30:58 -0000	1.75
+++ app_dial.c	21 Jun 2004 18:28:35 -0000	1.76
@@ -124,12 +124,11 @@
 
 #define MAX 256
 
-static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect)
+static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, int *sentringing)
 {
 	struct localuser *o;
 	int found;
 	int numlines;
-	int sentringing = 0;
 	int numbusies = 0;
 	int orig = *to;
 	struct ast_frame *f;
@@ -137,8 +136,6 @@
 	struct ast_channel *watchers[MAX];
 	int pos;
 	int single;
-	int moh=0;
-	int ringind=0;
 	struct ast_channel *winner;
 	
 	single = (outgoing && !outgoing->next && !outgoing->musiconhold && !outgoing->ringbackonly);
@@ -150,16 +147,6 @@
 		ast_channel_make_compatible(outgoing->chan, in);
 	}
 	
-	if (outgoing) {
-		moh = outgoing->musiconhold;
-		ringind = outgoing->ringbackonly;
-		if (outgoing->musiconhold) {
-			ast_moh_start(in, NULL);
-		} else if (outgoing->ringbackonly) {
-			ast_indicate(in, AST_CONTROL_RINGING);
-			sentringing++;
-		}
-	}
 	
 	while(*to && !peer) {
 		o = outgoing;
@@ -188,12 +175,6 @@
 					ast_verbose( VERBOSE_PREFIX_2 "No one is available to answer at this time\n");
 			}
 			*to = 0;
-			/* if no one available we'd better stop MOH/ringing to */
-			if (moh) {
-				ast_moh_stop(in);
-			} else if (sentringing) {
-				ast_indicate(in, -1);
-			}
 			return NULL;
 		}
 		winner = ast_waitfor_n(watchers, pos, to);
@@ -321,9 +302,9 @@
 						case AST_CONTROL_RINGING:
 							if (option_verbose > 2)
 								ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name);
-							if (!sentringing && !moh) {
+							if (!*sentringing && !outgoing->musiconhold) {
 								ast_indicate(in, AST_CONTROL_RINGING);
-								sentringing++;
+								*sentringing++;
 							}
 							break;
 						case AST_CONTROL_PROGRESS:
@@ -335,11 +316,11 @@
 							/* Ignore going off hook */
 							break;
 						case -1:
-							if (!ringind && !moh) {
+							if (!outgoing->ringbackonly && !outgoing->musiconhold) {
 								if (option_verbose > 2)
 									ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name);
 								ast_indicate(in, -1);
-								sentringing = 0;
+								*sentringing = 0;
 							}
 							break;
 						default:
@@ -393,11 +374,6 @@
 		if (!*to && (option_verbose > 2))
 			ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig);
 	}
-	if (moh) {
-		ast_moh_stop(in);
-	} else if (sentringing) {
-		ast_indicate(in, -1);
-	}
 
 	return peer;
 	
@@ -445,7 +421,7 @@
 	char sdtmfdata[256] = "";
 	char *stack,*var;
 	int play_to_caller=0,play_to_callee=0;
-	int playargs=0;
+	int playargs=0, sentringing=0, moh=0;
 	int digit = 0;
 
 	if (!data) {
@@ -840,7 +816,17 @@
 			ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", timeout);
 	} else
 		to = -1;
-	peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect);
+
+	if (outgoing->musiconhold) {
+		moh=1;
+		ast_moh_start(chan, NULL);
+	} else if (outgoing->ringbackonly) {
+		ast_indicate(chan, AST_CONTROL_RINGING);
+		sentringing++;
+	}
+
+	peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, &sentringing);
+
 	if (!peer) {
 		if (to) 
 			/* Musta gotten hung up */
@@ -917,6 +903,13 @@
 			config.warning_sound = warning_sound;
 			config.end_sound = end_sound;
 			config.start_sound = start_sound;
+			if (moh) {
+				moh = 0;
+				ast_moh_stop(chan);
+			} else if (sentringing) {
+				sentringing = 0;
+				ast_indicate(chan, -1);
+			}
 			res = ast_bridge_call(chan,peer,&config);
 		} else 
 			res = -1;
@@ -928,6 +921,13 @@
 		}
 	}	
 out:
+	if (moh) {
+		moh = 0;
+		ast_moh_stop(chan);
+	} else if (sentringing) {
+		sentringing = 0;
+		ast_indicate(chan, -1);
+	}
 	hanguptree(outgoing, NULL);
 	LOCAL_USER_REMOVE(u);
 	




More information about the svn-commits mailing list