[asterisk-commits] mmichelson: branch group/CCSS r231813 - in /team/group/CCSS: ./ apps/ channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 1 10:43:47 CST 2009


Author: mmichelson
Date: Tue Dec  1 10:43:37 2009
New Revision: 231813

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=231813
Log:
Resolve conflict and reset automerge.


Added:
    team/group/CCSS/main/asterisk.dynamics
      - copied unchanged from r231741, trunk/main/asterisk.dynamics
Modified:
    team/group/CCSS/   (props changed)
    team/group/CCSS/CHANGES
    team/group/CCSS/Makefile.rules
    team/group/CCSS/apps/app_chanspy.c
    team/group/CCSS/apps/app_dial.c
    team/group/CCSS/apps/app_externalivr.c
    team/group/CCSS/apps/app_fax.c
    team/group/CCSS/apps/app_followme.c
    team/group/CCSS/apps/app_meetme.c
    team/group/CCSS/apps/app_minivm.c
    team/group/CCSS/apps/app_mixmonitor.c
    team/group/CCSS/apps/app_osplookup.c
    team/group/CCSS/apps/app_queue.c
    team/group/CCSS/apps/app_voicemail.c
    team/group/CCSS/channels/chan_dahdi.c
    team/group/CCSS/channels/chan_iax2.c
    team/group/CCSS/channels/chan_sip.c
    team/group/CCSS/channels/sig_pri.c
    team/group/CCSS/channels/sig_pri.h
    team/group/CCSS/configs/manager.conf.sample
    team/group/CCSS/configs/sip.conf.sample
    team/group/CCSS/doc/CODING-GUIDELINES
    team/group/CCSS/doc/externalivr.txt
    team/group/CCSS/funcs/func_strings.c
    team/group/CCSS/include/asterisk/app.h
    team/group/CCSS/include/asterisk/audiohook.h
    team/group/CCSS/include/asterisk/channel.h
    team/group/CCSS/include/asterisk/file.h
    team/group/CCSS/include/asterisk/manager.h
    team/group/CCSS/include/asterisk/udptl.h
    team/group/CCSS/include/asterisk/unaligned.h
    team/group/CCSS/main/app.c
    team/group/CCSS/main/asterisk.c
    team/group/CCSS/main/audiohook.c
    team/group/CCSS/main/cdr.c
    team/group/CCSS/main/channel.c
    team/group/CCSS/main/features.c
    team/group/CCSS/main/file.c
    team/group/CCSS/main/manager.c
    team/group/CCSS/main/udptl.c
    team/group/CCSS/pbx/pbx_lua.c
    team/group/CCSS/res/res_monitor.c
    team/group/CCSS/res/res_musiconhold.c
    team/group/CCSS/res/res_rtp_asterisk.c

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Dec  1 10:43:37 2009
@@ -1,1 +1,1 @@
-/trunk:1-230052
+/trunk:1-231812

Modified: team/group/CCSS/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/CHANGES?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/CHANGES (original)
+++ team/group/CCSS/CHANGES Tue Dec  1 10:43:37 2009
@@ -101,6 +101,8 @@
    configuration for more information.
  * The ChanIsAvail application now exposes the returned cause code using a separate
    variable, AVAILCAUSECODE, instead of overwriting the device state in AVAILSTATUS.
+ * Added 'd' option to app_followme.  This option disables the "Please hold"
+   announcement.
 
 Dialplan Functions
 ------------------
@@ -146,8 +148,13 @@
    mode=multirow.  If rowlimit is set, then additional rows may be retrieved
    from the same query by using the name of the function which retrieved the
    first row as an argument to ODBC_FETCH().
-  * Added JABBER_RECEIVE, which permits receiving XMPP messages from the
-    dialplan. This function returns the content of the received message.
+ * Added JABBER_RECEIVE, which permits receiving XMPP messages from the
+   dialplan. This function returns the content of the received message.
+ * Added REPLACE, which searches a given variable name for a set of characters,
+   then either replaces them with a single character or deletes them.
+ * Added PASSTHRU, which literally passes the same argument back as its return
+   value.  The intent is to be able to use a literal string argument to
+   functions that currently require a variable name as an argument.
 
 Dialplan Variables
 ------------------
@@ -277,6 +284,9 @@
    but options with the 'tls' prefix are preferred.
  * Added a MuteAudio AMI action for muting inbound and/or outbound audio
    in a channel. (res_mutestream.so)
+ * The configuration file manager.conf now supports a channelvars option, which
+   specifies a list of channel variables to include in each channel-oriented
+   event.
 
 Channel Event Logging
 ---------------------

Modified: team/group/CCSS/Makefile.rules
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/Makefile.rules?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/Makefile.rules (original)
+++ team/group/CCSS/Makefile.rules Tue Dec  1 10:43:37 2009
@@ -49,7 +49,10 @@
 CXX_CFLAGS=$(PTHREAD_CFLAGS) $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_DECLARATION_AFTER_STATEMENT),$(_ASTCFLAGS) $(ASTCFLAGS))
 
 ifeq ($(GNU_LD),1)
-SO_SUPPRESS_SYMBOLS=-Wl,--version-script,$(if $(wildcard $(subst .so,.exports,$@)),$(subst .so,.exports,$@),$(ASTTOPDIR)/default.exports)
+SO_SUPPRESS_SYMBOLS=-Wl,--version-script,$(if $(wildcard $(subst .so,.exports,$@)),$(subst .so,.exports,$@),$(ASTTOPDIR)/default.exports),--warn-common
+ifneq ($(wildcard $(subst .so,.dynamics,$@)),)
+SO_SUPPRESS_SYMBOLS+=-Wl,--dynamic-list,$(subst .so,.dynamics,$@)
+endif
 endif
 
 CC_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(_ASTLDFLAGS) $(SOLINK) $(SO_SUPPRESS_SYMBOLS) $(ASTLDFLAGS)

Modified: team/group/CCSS/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_chanspy.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_chanspy.c (original)
+++ team/group/CCSS/apps/app_chanspy.c Tue Dec  1 10:43:37 2009
@@ -513,6 +513,7 @@
 	struct ast_silence_generator *silgen = NULL;
 	struct ast_autochan *spyee_bridge_autochan = NULL;
 	const char *spyer_name;
+	struct ast_channel *chans[] = { chan, spyee_autochan->chan };
 
 	ast_channel_lock(chan);
 	spyer_name = ast_strdupa(chan->name);
@@ -529,7 +530,7 @@
 	ast_channel_unlock(spyee_autochan->chan);
 
 	ast_verb(2, "Spying on channel %s\n", name);
-	manager_event(EVENT_FLAG_CALL, "ChanSpyStart",
+	ast_manager_event_multichan(EVENT_FLAG_CALL, "ChanSpyStart", 2, chans,
 			"SpyerChannel: %s\r\n"
 			"SpyeeChannel: %s\r\n",
 			spyer_name, name);
@@ -697,7 +698,7 @@
 	}
 
 	ast_verb(2, "Done Spying on channel %s\n", name);
-	manager_event(EVENT_FLAG_CALL, "ChanSpyStop", "SpyeeChannel: %s\r\n", name);
+	ast_manager_event(chan, EVENT_FLAG_CALL, "ChanSpyStop", "SpyeeChannel: %s\r\n", name);
 
 	return running;
 }

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Tue Dec  1 10:43:37 2009
@@ -723,7 +723,8 @@
 
 static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
 {
-	manager_event(EVENT_FLAG_CALL, "Dial",
+	struct ast_channel *chans[] = { src, dst };
+	ast_manager_event_multichan(EVENT_FLAG_CALL, "Dial", 2, chans,
 		"SubEvent: Begin\r\n"
 		"Channel: %s\r\n"
 		"Destination: %s\r\n"
@@ -737,9 +738,9 @@
 		dst->uniqueid, dialstring ? dialstring : "");
 }
 
-static void senddialendevent(const struct ast_channel *src, const char *dialstatus)
+static void senddialendevent(struct ast_channel *src, const char *dialstatus)
 {
-	manager_event(EVENT_FLAG_CALL, "Dial",
+	ast_manager_event(src, EVENT_FLAG_CALL, "Dial",
 		"SubEvent: End\r\n"
 		"Channel: %s\r\n"
 		"UniqueID: %s\r\n"

Modified: team/group/CCSS/apps/app_externalivr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_externalivr.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_externalivr.c (original)
+++ team/group/CCSS/apps/app_externalivr.c Tue Dec  1 10:43:37 2009
@@ -95,6 +95,19 @@
 /* XXX the parser in gcc 2.95 gets confused if you don't put a space between 'name' and the comma */
 #define ast_chan_log(level, channel, format, ...) ast_log(level, "%s: " format, channel->name , ## __VA_ARGS__)
 
+/* Commands */
+#define EIVR_CMD_PARM 'P' /* return supplied params */
+#define EIVR_CMD_ANS 'T'  /* answer channel */
+#define EIVR_CMD_SQUE 'S' /* (re)set prompt queue */
+#define EIVR_CMD_APND 'A' /* append to prompt queue */
+#define EIVR_CMD_GET 'G'  /* get channel varable(s) */
+#define EIVR_CMD_SVAR 'V' /* set channel varable(s) */
+#define EIVR_CMD_LOG 'L'  /* log message */
+#define EIVR_CMD_XIT 'X'  /* exit **depricated** */
+#define EIVR_CMD_EXIT 'E' /* exit */
+#define EIVR_CMD_HGUP 'H' /* hangup */
+#define EIVR_CMD_OPT 'O'  /* option */
+
 enum options_flags {
 	noanswer = (1 << 0),
 	ignore_hangup = (1 << 1),
@@ -361,10 +374,11 @@
 	char *buf;
 	int j;
 	char *s, **app_args, *e; 
-	struct ast_str *pipe_delim_args = ast_str_create(100);
+	struct ast_str *comma_delim_args = ast_str_alloca(100);
 
 	AST_DECLARE_APP_ARGS(eivr_args,
-		AST_APP_ARG(cmd)[32];
+		AST_APP_ARG(application);
+		AST_APP_ARG(options);
 	);
 	AST_DECLARE_APP_ARGS(application_args,
 		AST_APP_ARG(cmd)[32];
@@ -374,65 +388,65 @@
 	u->chan = chan;
 
 	if (ast_strlen_zero(data)) {
-		ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
-		return -1;
+		ast_log(LOG_ERROR, "ExternalIVR requires a command to execute\n");
+		goto exit;
 	}
 
 	buf = ast_strdupa(data);
 	AST_STANDARD_APP_ARGS(eivr_args, buf);
 
-	if ((s = strchr(eivr_args.cmd[0], '('))) {
+	ast_verb(4, "ExternalIVR received application and arguments: %s\n", eivr_args.application);
+	ast_verb(4, "ExternalIVR received options: %s\n", eivr_args.options);
+
+	/* Parse out any application arguments */
+	if ((s = strchr(eivr_args.application, '('))) {
 		s[0] = ',';
-		if (( e = strrchr(s, ')')) ) {
+		if ((e = strrchr(s, ')'))) {
 			*e = '\0';
 		} else {
-			ast_log(LOG_ERROR, "Parse error, no closing paren?\n");
-		}
-		AST_STANDARD_APP_ARGS(application_args, eivr_args.cmd[0]);
-		app_args = application_args.argv;
-
-		/* Put the application + the arguments in a | delimited list */
-		ast_str_reset(pipe_delim_args);
-		for (j = 0; application_args.cmd[j] != NULL; j++) {
-			ast_str_append(&pipe_delim_args, 0, "%s%s", j == 0 ? "" : ",", application_args.cmd[j]);
-		}
-
-		/* Parse the ExternalIVR() arguments */
-		if (option_debug)
-			ast_debug(1, "Parsing options from: [%s]\n", eivr_args.cmd[1]);
-		ast_app_parse_options(app_opts, &flags, opts, eivr_args.cmd[1]);
-		if (option_debug) {
-			if (ast_test_flag(&flags, noanswer))
-				ast_debug(1, "noanswer is set\n");
-			if (ast_test_flag(&flags, ignore_hangup))
-				ast_debug(1, "ignore_hangup is set\n");
-			if (ast_test_flag(&flags, run_dead))
-				ast_debug(1, "run_dead is set\n");
-		}
-
-	} else {
-		app_args = eivr_args.argv;
-		for (j = 0; eivr_args.cmd[j] != NULL; j++) {
-			ast_str_append(&pipe_delim_args, 0, "%s%s", j == 0 ? "" : "|", eivr_args.cmd[j]);
-		}
+			ast_log(LOG_ERROR, "Parse error, missing closing parenthesis\n");
+			goto exit;
+		}
+	}
+
+	AST_STANDARD_APP_ARGS(application_args, eivr_args.application);
+	app_args = application_args.argv;
+
+	/* Put the application + the arguments in a , delimited list */
+	ast_str_reset(comma_delim_args);
+	for (j = 0; application_args.cmd[j] != NULL; j++) {
+		ast_str_append(&comma_delim_args, 0, "%s%s", j == 0 ? "" : ",", application_args.cmd[j]);
+	}
+
+	/* Get rid of any extraneous arguments */
+	if ((s = strchr(eivr_args.options, ','))) {
+		*s = '\0';
+	}
+
+	/* Parse the ExternalIVR() arguments */
+	ast_verb(4, "Parsing options from: [%s]\n", eivr_args.options);
+	ast_app_parse_options(app_opts, &flags, opts, eivr_args.options);
+	if (ast_test_flag(&flags, noanswer)) {
+		ast_verb(4, "noanswer is set\n");
+	}
+	if (ast_test_flag(&flags, ignore_hangup)) {
+		ast_verb(4, "ignore_hangup is set\n");
+	}
+	if (ast_test_flag(&flags, run_dead)) {
+		ast_verb(4, "run_dead is set\n");
 	}
 	
-	if (ast_strlen_zero(data)) {
-		ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
-		return -1;
-	}
-
 	if (!(ast_test_flag(&flags, noanswer))) {
-		ast_chan_log(LOG_WARNING, chan, "Answering channel and starting generator\n");
+		ast_verb(3, "Answering channel and starting generator\n");
 		if (chan->_state != AST_STATE_UP) {
 			if (ast_test_flag(&flags, run_dead)) {
-				ast_chan_log(LOG_WARNING, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n");
+				ast_chan_log(LOG_ERROR, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n");
 				goto exit;
 			}
 			ast_answer(chan);
 		}
 		if (ast_activate_generator(chan, &gen, u) < 0) {
-			ast_chan_log(LOG_WARNING, chan, "Failed to activate generator\n");
+			ast_chan_log(LOG_ERROR, chan, "Failed to activate generator\n");
 			goto exit;
 		} else {
 			u->gen_active = 1;
@@ -465,26 +479,26 @@
 		if (!(ser = ast_tcptls_client_create(&ivr_desc)) || !(ser = ast_tcptls_client_start(ser))) {
 			goto exit;
 		}
-		res = eivr_comm(chan, u, ser->fd, ser->fd, -1, pipe_delim_args, flags);
+		res = eivr_comm(chan, u, ser->fd, ser->fd, -1, comma_delim_args, flags);
 
 	} else {
 	
 		if (pipe(child_stdin)) {
-			ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child input: %s\n", strerror(errno));
+			ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child input: %s\n", strerror(errno));
 			goto exit;
 		}
 		if (pipe(child_stdout)) {
-			ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child output: %s\n", strerror(errno));
+			ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child output: %s\n", strerror(errno));
 			goto exit;
 		}
 		if (pipe(child_stderr)) {
-			ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child errors: %s\n", strerror(errno));
+			ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child errors: %s\n", strerror(errno));
 			goto exit;
 		}
 	
 		pid = ast_safe_fork(0);
 		if (pid < 0) {
-			ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
+			ast_log(LOG_ERROR, "Failed to fork(): %s\n", strerror(errno));
 			goto exit;
 		}
 	
@@ -508,37 +522,38 @@
 			child_stdout[1] = 0;
 			close(child_stderr[1]);
 			child_stderr[1] = 0;
-			res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], pipe_delim_args, flags);
+			res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], comma_delim_args, flags);
 		}
 	}
 
 	exit:
-	if (u->gen_active)
+	if (u->gen_active) {
 		ast_deactivate_generator(chan);
-
-	if (child_stdin[0])
+	}
+	if (child_stdin[0]) {
 		close(child_stdin[0]);
-
-	if (child_stdin[1])
+	}
+	if (child_stdin[1]) {
 		close(child_stdin[1]);
-
-	if (child_stdout[0])
+	}
+	if (child_stdout[0]) {
 		close(child_stdout[0]);
-
-	if (child_stdout[1])
+	}
+	if (child_stdout[1]) {
 		close(child_stdout[1]);
-
-	if (child_stderr[0])
+	}
+	if (child_stderr[0]) {
 		close(child_stderr[0]);
-
-	if (child_stderr[1])
+	}
+	if (child_stderr[1]) {
 		close(child_stderr[1]);
+	}
 	if (ser) {
 		ao2_ref(ser, -1);
 	}
-	while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
+	while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
 		ast_free(entry);
-
+	}
 	return res;
 }
 
@@ -553,7 +568,6 @@
  	int ready_fd;
  	int waitfds[2] = { eivr_commands_fd, eivr_errors_fd };
  	struct ast_channel *rchan;
- 	char *command;
  	int res = -1;
 	int test_available_fd = -1;
 	int hangup_info_sent = 0;
@@ -563,16 +577,16 @@
  	FILE *eivr_events = NULL;
 
 	if (!(eivr_events = fdopen(eivr_events_fd, "w"))) {
-		ast_chan_log(LOG_WARNING, chan, "Could not open stream to send events\n");
+		ast_chan_log(LOG_ERROR, chan, "Could not open stream to send events\n");
 		goto exit;
 	}
 	if (!(eivr_commands = fdopen(eivr_commands_fd, "r"))) {
-		ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive commands\n");
+		ast_chan_log(LOG_ERROR, chan, "Could not open stream to receive commands\n");
 		goto exit;
 	}
 	if (eivr_errors_fd > -1) {  /* if opening a socket connection, error stream will not be used */
  		if (!(eivr_errors = fdopen(eivr_errors_fd, "r"))) {
- 			ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive errors\n");
+ 			ast_chan_log(LOG_ERROR, chan, "Could not open stream to receive errors\n");
  			goto exit;
  		}
 	}
@@ -585,23 +599,19 @@
 		setvbuf(eivr_errors, NULL, _IONBF, 0);
 	}
 
-	res = 0;
- 
  	while (1) {
  		if (ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
- 			ast_chan_log(LOG_NOTICE, chan, "Is a zombie\n");
- 			res = -1;
+ 			ast_chan_log(LOG_ERROR, chan, "Is a zombie\n");
  			break;
  		}
  		if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) {
 			if (ast_test_flag(&flags, ignore_hangup)) {
-				ast_chan_log(LOG_NOTICE, chan, "Got check_hangup, but ignore_hangup set so sending 'I' command\n");
+				ast_verb(3, "Got check_hangup, but ignore_hangup set so sending 'I' command\n");
 				send_eivr_event(eivr_events, 'I', "HANGUP", chan);
 				hangup_info_sent = 1;
 			} else {
- 				ast_chan_log(LOG_NOTICE, chan, "Got check_hangup\n");
+ 				ast_verb(3, "Got check_hangup\n");
  				send_eivr_event(eivr_events, 'H', NULL, chan);
- 				res = -1;
 	 			break;
 			}
  		}
@@ -626,9 +636,8 @@
  			/* the channel has something */
  			f = ast_read(chan);
  			if (!f) {
- 				ast_chan_log(LOG_NOTICE, chan, "Returned no frame\n");
+ 				ast_verb(3, "Returned no frame\n");
  				send_eivr_event(eivr_events, 'H', NULL, chan);
- 				res = -1;
  				break;
  			}
  			if (f->frametype == AST_FRAME_DTMF) {
@@ -646,13 +655,12 @@
   					AST_LIST_UNLOCK(&u->playlist);
   				}
  			} else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
- 				ast_chan_log(LOG_NOTICE, chan, "Got AST_CONTROL_HANGUP\n");
+ 				ast_verb(3, "Got AST_CONTROL_HANGUP\n");
  				send_eivr_event(eivr_events, 'H', NULL, chan);
 				if (f->data.uint32) {
 					chan->hangupcause = f->data.uint32;
 				}
  				ast_frfree(f);
- 				res = -1;
  				break;
  			}
  			ast_frfree(f);
@@ -660,34 +668,35 @@
  			char input[1024];
  
  			if (exception || (dup2(eivr_commands_fd, test_available_fd) == -1) || feof(eivr_commands)) {
- 				ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
- 				res = -1;
+ 				ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
   				break;
   			}
   
  			if (!fgets(input, sizeof(input), eivr_commands))
  				continue;
  
- 			command = ast_strip(input);
+ 			ast_verb(4, "got command '%s'\n", ast_strip(input));
   
- 			if (option_debug)
- 				ast_debug(1, "got command '%s'\n", input);
+ 			if (strlen(input) < 4) {
+ 				continue;
+			}
   
- 			if (strlen(input) < 4)
- 				continue;
-  
-			if (input[0] == 'P') {
+			if (input[0] == EIVR_CMD_PARM) {
 				struct ast_str *tmp = (struct ast_str *) args;
  				send_eivr_event(eivr_events, 'P', ast_str_buffer(tmp), chan);
-			} else if ( input[0] == 'T' ) {
-				ast_chan_log(LOG_WARNING, chan, "Answering channel if needed and starting generator\n");
+			} else if (input[0] == EIVR_CMD_ANS) {
+				ast_verb(3, "Answering channel if needed and starting generator\n");
 				if (chan->_state != AST_STATE_UP) {
 					if (ast_test_flag(&flags, run_dead)) {
 						ast_chan_log(LOG_WARNING, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n");
 						send_eivr_event(eivr_events, 'Z', "ANSWER_FAILURE", chan);
 						continue;
 					}
-					ast_answer(chan);
+					if (ast_answer(chan)) {
+						ast_chan_log(LOG_WARNING, chan, "Failed to answer channel\n");
+						send_eivr_event(eivr_events, 'Z', "ANSWER_FAILURE", chan);
+						continue;
+					}
 				}
 				if (!(u->gen_active)) {
 					if (ast_activate_generator(chan, &gen, u) < 0) {
@@ -697,23 +706,23 @@
 						u->gen_active = 1;
 					}
 				}
- 			} else if (input[0] == 'S') {
+ 			} else if (input[0] == EIVR_CMD_SQUE) {
 				if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
-					ast_chan_log(LOG_WARNING, chan, "Queue 'S'et called on unanswered channel\n");
+					ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n");
 					send_eivr_event(eivr_events, 'Z', NULL, chan);
 					continue;
 				}
- 				if (ast_fileexists(&input[2], NULL, u->chan->language) == -1) {
+ 				if (!ast_fileexists(&input[2], NULL, u->chan->language)) {
  					ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
- 					send_eivr_event(eivr_events, 'Z', NULL, chan);
- 					strcpy(&input[2], "exception");
- 				}
- 				if (!u->abort_current_sound && !u->playing_silence)
- 					send_eivr_event(eivr_events, 'T', NULL, chan);
- 				AST_LIST_LOCK(&u->playlist);
- 				while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
- 					send_eivr_event(eivr_events, 'D', entry->filename, chan);
- 					ast_free(entry);
+ 					send_eivr_event(eivr_events, 'Z', &input[2], chan);
+ 				} else {
+	 				if (!u->abort_current_sound && !u->playing_silence)
+ 						send_eivr_event(eivr_events, 'T', NULL, chan);
+ 					AST_LIST_LOCK(&u->playlist);
+ 					while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
+ 						send_eivr_event(eivr_events, 'D', entry->filename, chan);
+ 						ast_free(entry);
+					}
  				}
  				if (!u->playing_silence)
  					u->abort_current_sound = 1;
@@ -721,52 +730,48 @@
  				if (entry)
  					AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
  				AST_LIST_UNLOCK(&u->playlist);
- 			} else if (input[0] == 'A') {
+ 			} else if (input[0] == EIVR_CMD_APND) {
 				if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
 					ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");
 					send_eivr_event(eivr_events, 'Z', NULL, chan);
 					continue;
 				}
- 				if (ast_fileexists(&input[2], NULL, u->chan->language) == -1) {
+ 				if (!ast_fileexists(&input[2], NULL, u->chan->language)) {
  					ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
- 					send_eivr_event(eivr_events, 'Z', NULL, chan);
- 					strcpy(&input[2], "exception");
+ 					send_eivr_event(eivr_events, 'Z', &input[2], chan);
+ 				} else {
+	 				entry = make_entry(&input[2]);
+ 					if (entry) {
+ 						AST_LIST_LOCK(&u->playlist);
+ 						AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
+ 						AST_LIST_UNLOCK(&u->playlist);
+					}
  				}
- 				entry = make_entry(&input[2]);
- 				if (entry) {
- 					AST_LIST_LOCK(&u->playlist);
- 					AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
- 					AST_LIST_UNLOCK(&u->playlist);
- 				}
- 			} else if (input[0] == 'G') {
- 				/* A get variable message:  "G,variable1,variable2,..." */
+ 			} else if (input[0] == EIVR_CMD_GET) {
  				char response[2048];
-
- 				ast_chan_log(LOG_NOTICE, chan, "Getting a Variable out of the channel: %s\n", &input[2]);
+				ast_verb(4, "Retriving Variables from channel: %s\n", &input[2]);
  				ast_eivr_getvariable(chan, &input[2], response, sizeof(response));
  				send_eivr_event(eivr_events, 'G', response, chan);
- 			} else if (input[0] == 'V') {
- 				/* A set variable message:  "V,variablename=foo" */
- 				ast_chan_log(LOG_NOTICE, chan, "Setting a Variable up: %s\n", &input[2]);
+ 			} else if (input[0] == EIVR_CMD_SVAR) {
+				ast_verb(4, "Setting Variables in channel: %s\n", &input[2]);
  				ast_eivr_setvariable(chan, &input[2]);
- 			} else if (input[0] == 'L') {
+ 			} else if (input[0] == EIVR_CMD_LOG) {
  				ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]);
- 			} else if (input[0] == 'X') {
- 				ast_chan_log(LOG_NOTICE, chan, "Exiting ExternalIVR: %s\n", &input[2]);
- 				/*! \todo add deprecation debug message for X command here */
+ 			} else if (input[0] == EIVR_CMD_XIT) {
+ 				ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
+				ast_chan_log(LOG_WARNING, chan, "e'X'it command is depricated, use 'E'xit instead\n");
  				res = 0;
  				break;
-			} else if (input[0] == 'E') {
+			} else if (input[0] == EIVR_CMD_EXIT) {
  				ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
  				send_eivr_event(eivr_events, 'E', NULL, chan);
  				res = 0;
  				break;
- 			} else if (input[0] == 'H') {
+ 			} else if (input[0] == EIVR_CMD_HGUP) {
  				ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]);
  				send_eivr_event(eivr_events, 'H', NULL, chan);
- 				res = -1;
  				break;
- 			} else if (input[0] == 'O') {
+ 			} else if (input[0] == EIVR_CMD_OPT) {
 				if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
 					ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n");
 					send_eivr_event(eivr_events, 'Z', NULL, chan);
@@ -777,25 +782,23 @@
  				else if (!strcasecmp(&input[2], "noautoclear"))
  					u->option_autoclear = 0;
  				else
- 					ast_chan_log(LOG_WARNING, chan, "Unknown option requested '%s'\n", &input[2]);
+ 					ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]);
  			}
  		} else if (eivr_errors_fd && ready_fd == eivr_errors_fd) {
  			char input[1024];
   
  			if (exception || feof(eivr_errors)) {
- 				ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
- 				res = -1;
+ 				ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
  				break;
  			}
  			if (fgets(input, sizeof(input), eivr_errors)) {
- 				command = ast_strip(input);
- 				ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", command);
+ 				ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input));
  			}
  		} else if ((ready_fd < 0) && ms) { 
  			if (errno == 0 || errno == EINTR)
  				continue;
  
- 			ast_chan_log(LOG_WARNING, chan, "Wait failed (%s)\n", strerror(errno));
+ 			ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno));
  			break;
  		}
  	}

Modified: team/group/CCSS/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_fax.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_fax.c (original)
+++ team/group/CCSS/apps/app_fax.c Tue Dec  1 10:43:37 2009
@@ -248,7 +248,7 @@
 	ast_debug(1, "  Image resolution:  %d x %d\n", stat.x_resolution, stat.y_resolution);
 	ast_debug(1, "  Transfer Rate:     %d\n", stat.bit_rate);
 	
-	manager_event(EVENT_FLAG_CALL,
+	ast_manager_event(s->chan, EVENT_FLAG_CALL,
 		      s->direction ? "FaxSent" : "FaxReceived", 
 		      "Channel: %s\r\n"
 		      "Exten: %s\r\n"
@@ -598,7 +598,6 @@
 	struct timeval now, start, state_change, last_frame;
 	t30_state_t *t30state;
 	t38_core_state_t *t38state;
-	struct ast_control_t38_parameters t38_parameters = { .request_response = AST_T38_REQUEST_TERMINATE, };
 
 #if SPANDSP_RELEASE_DATE >= 20080725
 	/* for spandsp shaphots 0.0.6 and higher */
@@ -706,7 +705,13 @@
 	t38_terminal_release(&t38);
 
 disable_t38:
-	if (ast_channel_get_t38_state(s->chan) == T38_STATE_NEGOTIATED) {
+	/* if we are not the caller, it's our job to shut down the T.38
+	 * session when the FAX transmisson is complete.
+	 */
+	if ((s->caller_mode == FALSE) &&
+	    (ast_channel_get_t38_state(s->chan) == T38_STATE_NEGOTIATED)) {
+		struct ast_control_t38_parameters t38_parameters = { .request_response = AST_T38_REQUEST_TERMINATE, };
+
 		if (ast_indicate_data(s->chan, AST_CONTROL_T38_PARAMETERS, &t38_parameters, sizeof(t38_parameters)) == 0) {
 			/* wait up to five seconds for negotiation to complete */
 			unsigned int timeout = 5000;
@@ -738,7 +743,7 @@
 					struct ast_control_t38_parameters *parameters = inf->data.ptr;
 					
 					switch (parameters->request_response) {
-					case AST_T38_NEGOTIATED:
+					case AST_T38_TERMINATED:
 						ast_debug(1, "Shut down T.38 on %s\n", s->chan->name);
 						break;
 					case AST_T38_REFUSED:

Modified: team/group/CCSS/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_followme.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_followme.c (original)
+++ team/group/CCSS/apps/app_followme.c Tue Dec  1 10:43:37 2009
@@ -79,6 +79,9 @@
 						<para>Playback the unreachable status message if we've run out
 						of steps to reach the or the callee has elected not to be reachable.</para>
 					</option>
+					<option name="d">
+						<para>Disable the 'Please hold while we try to connect your call' announcement.</para>
+					</option>
 				</optionlist>
 			</parameter>
 		</syntax>
@@ -159,13 +162,15 @@
 enum {
 	FOLLOWMEFLAG_STATUSMSG = (1 << 0),
 	FOLLOWMEFLAG_RECORDNAME = (1 << 1),
-	FOLLOWMEFLAG_UNREACHABLEMSG = (1 << 2)
+	FOLLOWMEFLAG_UNREACHABLEMSG = (1 << 2),
+	FOLLOWMEFLAG_DISABLEHOLDPROMPT = (1 << 3)
 };
 
 AST_APP_OPTIONS(followme_opts, {
 	AST_APP_OPTION('s', FOLLOWMEFLAG_STATUSMSG ),
 	AST_APP_OPTION('a', FOLLOWMEFLAG_RECORDNAME ),
 	AST_APP_OPTION('n', FOLLOWMEFLAG_UNREACHABLEMSG ),
+	AST_APP_OPTION('d', FOLLOWMEFLAG_DISABLEHOLDPROMPT ),
 });
 
 static int ynlongest = 0;
@@ -1095,11 +1100,12 @@
 
 	if (!ast_fileexists(namerecloc, NULL, chan->language))
 		ast_copy_string(namerecloc, "", sizeof(namerecloc));
-
-	if (ast_streamfile(chan, targs.plsholdprompt, chan->language))
-		goto outrun;
-	if (ast_waitstream(chan, "") < 0)
-		goto outrun;
+	if (!ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_DISABLEHOLDPROMPT)) {
+		if (ast_streamfile(chan, targs.plsholdprompt, chan->language))
+			goto outrun;
+		if (ast_waitstream(chan, "") < 0)
+			goto outrun;
+	}
 	ast_moh_start(chan, S_OR(targs.mohclass, NULL), NULL);
 
 	targs.status = 0;

Modified: team/group/CCSS/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_meetme.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_meetme.c (original)
+++ team/group/CCSS/apps/app_meetme.c Tue Dec  1 10:43:37 2009
@@ -2508,7 +2508,7 @@
 	ast_debug(1, "Placed channel %s in DAHDI conf %d\n", chan->name, conf->dahdiconf);
 
 	if (!sent_event) {
-		manager_event(EVENT_FLAG_CALL, "MeetmeJoin", 
+		ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeJoin",
 			        "Channel: %s\r\n"
 			        "Uniqueid: %s\r\n"
 				"Meetme: %s\r\n"
@@ -2837,7 +2837,7 @@
 					break;
 				}
 
-				manager_event(EVENT_FLAG_CALL, "MeetmeMute", 
+				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute",
 						"Channel: %s\r\n"
 						"Uniqueid: %s\r\n"
 						"Meetme: %s\r\n"
@@ -2855,7 +2855,7 @@
 					break;
 				}
 
-				manager_event(EVENT_FLAG_CALL, "MeetmeMute", 
+				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute",
 						"Channel: %s\r\n"
 						"Uniqueid: %s\r\n"
 						"Meetme: %s\r\n"
@@ -2868,7 +2868,7 @@
 				(user->adminflags & ADMINFLAG_T_REQUEST) && !(talkreq_manager)) {
 				talkreq_manager = 1;
 
-				manager_event(EVENT_FLAG_CALL, "MeetmeTalkRequest", 
+				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest",
 					      "Channel: %s\r\n"
 							      "Uniqueid: %s\r\n"
 							      "Meetme: %s\r\n"
@@ -2881,7 +2881,7 @@
 			if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && 
 				!(user->adminflags & ADMINFLAG_T_REQUEST) && (talkreq_manager)) {
 				talkreq_manager = 0;
-				manager_event(EVENT_FLAG_CALL, "MeetmeTalkRequest", 
+				ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest",
 					      "Channel: %s\r\n"
 							      "Uniqueid: %s\r\n"
 							      "Meetme: %s\r\n"
@@ -2949,7 +2949,7 @@
 						if (!user->talking && totalsilence < MEETME_DELAYDETECTTALK) {
 							user->talking = 1;
 							if (confflags & CONFFLAG_MONITORTALKER)
-								manager_event(EVENT_FLAG_CALL, "MeetmeTalking",
+								ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalking",
 								      "Channel: %s\r\n"
 								      "Uniqueid: %s\r\n"
 								      "Meetme: %s\r\n"
@@ -2960,7 +2960,7 @@
 						if (user->talking && totalsilence > MEETME_DELAYDETECTENDTALK) {
 							user->talking = 0;
 							if (confflags & CONFFLAG_MONITORTALKER) {
-								manager_event(EVENT_FLAG_CALL, "MeetmeTalking",
+								ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalking",
 								      "Channel: %s\r\n"
 								      "Uniqueid: %s\r\n"
 								      "Meetme: %s\r\n"
@@ -3384,7 +3384,7 @@
 		sec = (now.tv_sec - user->jointime) % 60;
 
 		if (sent_event) {
-			manager_event(EVENT_FLAG_CALL, "MeetmeLeave",
+			ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
 				      "Channel: %s\r\n"
 				      "Uniqueid: %s\r\n"
 				      "Meetme: %s\r\n"

Modified: team/group/CCSS/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_minivm.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_minivm.c (original)
+++ team/group/CCSS/apps/app_minivm.c Tue Dec  1 10:43:37 2009
@@ -1806,7 +1806,7 @@
 		res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_PAGE, counter);
 	}
 
-	manager_event(EVENT_FLAG_CALL, "MiniVoiceMail", "Action: SentNotification\rn\nMailbox: %s@%s\r\nCounter: %s\r\n", vmu->username, vmu->domain, counter);
+	ast_manager_event(chan, EVENT_FLAG_CALL, "MiniVoiceMail", "Action: SentNotification\rn\nMailbox: %s@%s\r\nCounter: %s\r\n", vmu->username, vmu->domain, counter);
 
 	run_externnotify(chan, vmu);		/* Run external notification */
 

Modified: team/group/CCSS/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_mixmonitor.c?view=diff&rev=231813&r1=231812&r2=231813
==============================================================================
--- team/group/CCSS/apps/app_mixmonitor.c (original)
+++ team/group/CCSS/apps/app_mixmonitor.c Tue Dec  1 10:43:37 2009
@@ -177,19 +177,21 @@
 	 * immediately during stop_mixmonitor or channel destruction. */
 	int fs_quit;
 	struct ast_filestream *fs;
-
+	struct ast_audiohook *audiohook;
 };
 
+/*!
+ * \internal
+ * \pre mixmonitor_ds must be locked before calling this function
+ */
 static void mixmonitor_ds_close_fs(struct mixmonitor_ds *mixmonitor_ds)
 {
-	ast_mutex_lock(&mixmonitor_ds->lock);
 	if (mixmonitor_ds->fs) {
 		ast_closestream(mixmonitor_ds->fs);
 		mixmonitor_ds->fs = NULL;
 		mixmonitor_ds->fs_quit = 1;
 		ast_verb(2, "MixMonitor close filestream\n");
 	}
-	ast_mutex_unlock(&mixmonitor_ds->lock);
 }
 
 static void mixmonitor_ds_destroy(void *data)
@@ -197,6 +199,7 @@
 	struct mixmonitor_ds *mixmonitor_ds = data;
 
 	ast_mutex_lock(&mixmonitor_ds->lock);
+	mixmonitor_ds->audiohook = NULL;
 	mixmonitor_ds->destruction_ok = 1;
 	ast_cond_signal(&mixmonitor_ds->destruction_condition);
 	ast_mutex_unlock(&mixmonitor_ds->lock);
@@ -206,6 +209,20 @@
 	.type = "mixmonitor",
 	.destroy = mixmonitor_ds_destroy,
 };
+
+static void destroy_monitor_audiohook(struct mixmonitor *mixmonitor)
+{
+	if (mixmonitor->mixmonitor_ds) {
+		ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
+		mixmonitor->mixmonitor_ds->audiohook = NULL;
+		ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
+	}
+	/* kill the audiohook.*/
+	ast_audiohook_lock(&mixmonitor->audiohook);
+	ast_audiohook_detach(&mixmonitor->audiohook);
+	ast_audiohook_unlock(&mixmonitor->audiohook);
+	ast_audiohook_destroy(&mixmonitor->audiohook);
+}
 
 static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook) 
 {
@@ -246,10 +263,10 @@
 
 	ast_verb(2, "Begin MixMonitor Recording %s\n", mixmonitor->name);
 
+	fs = &mixmonitor->mixmonitor_ds->fs;
+
+	/* The audiohook must enter and exit the loop locked */
 	ast_audiohook_lock(&mixmonitor->audiohook);
-
-	fs = &mixmonitor->mixmonitor_ds->fs;
-
 	while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING && !mixmonitor->mixmonitor_ds->fs_quit) {
 		struct ast_frame *fr = NULL;
 
@@ -260,6 +277,10 @@
 
 		if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
 			continue;
+
+		/* audiohook lock is not required for the next block.
+		 * Unlock it, but remember to lock it before looping or exiting */
+		ast_audiohook_unlock(&mixmonitor->audiohook);
 
 		if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) || (mixmonitor->autochan->chan && ast_bridged_channel(mixmonitor->autochan->chan))) {
 			ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
@@ -292,28 +313,27 @@
 		/* All done! free it. */
 		ast_frame_free(fr, 0);
 
-	}
-
-	ast_audiohook_detach(&mixmonitor->audiohook);
+		ast_audiohook_lock(&mixmonitor->audiohook);
+	}
 	ast_audiohook_unlock(&mixmonitor->audiohook);
-	ast_audiohook_destroy(&mixmonitor->audiohook);
-
+
+	ast_autochan_destroy(mixmonitor->autochan);
+
+	/* Datastore cleanup.  close the filestream and wait for ds destruction */
+	ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
 	mixmonitor_ds_close_fs(mixmonitor->mixmonitor_ds);
-
+	if (!mixmonitor->mixmonitor_ds->destruction_ok) {
+		ast_cond_wait(&mixmonitor->mixmonitor_ds->destruction_condition, &mixmonitor->mixmonitor_ds->lock);
+	}
+	ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
+
+	/* kill the audiohook */
+	destroy_monitor_audiohook(mixmonitor);
 
 	if (mixmonitor->post_process) {
 		ast_verb(2, "Executing [%s]\n", mixmonitor->post_process);
 		ast_safe_system(mixmonitor->post_process);
 	}
-
-	ast_autochan_destroy(mixmonitor->autochan);
-
-	ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
-	if (!mixmonitor->mixmonitor_ds->destruction_ok) {
-		ast_cond_wait(&mixmonitor->mixmonitor_ds->destruction_condition, &mixmonitor->mixmonitor_ds->lock);
-	}
-	ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
-
 
 	ast_verb(2, "End MixMonitor Recording %s\n", mixmonitor->name);
 	mixmonitor_free(mixmonitor);
@@ -339,6 +359,7 @@
 		return -1;
 	}
 
+	mixmonitor_ds->audiohook = &mixmonitor->audiohook;
 	datastore->data = mixmonitor_ds;
 
 	ast_channel_lock(chan);
@@ -380,6 +401,12 @@
 		return;
 	}
 
+	/* Setup the actual spy before creating our thread */
+	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
+		mixmonitor_free(mixmonitor);
+		return;
+	}
+
 	/* Copy over flags and channel name */
 	mixmonitor->flags = flags;
 	if (!(mixmonitor->autochan = ast_autochan_setup(chan))) {
@@ -401,12 +428,6 @@
 
 	mixmonitor->filename = (char *) mixmonitor + sizeof(*mixmonitor) + strlen(chan->name) + 1;
 	strcpy(mixmonitor->filename, filename);
-
-	/* Setup the actual spy before creating our thread */
-	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
-		mixmonitor_free(mixmonitor);
-		return;
-	}
 
 	ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_SYNC);
 
@@ -511,13 +532,36 @@
 {
 	struct ast_datastore *datastore = NULL;
 
-	/* closing the filestream here guarantees the file is avaliable to the dialplan
-	 * after calling StopMixMonitor */
+	ast_channel_lock(chan);
+	ast_audiohook_detach_source(chan, mixmonitor_spy_type);
 	if ((datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info, NULL))) {
-		mixmonitor_ds_close_fs(datastore->data);
-	}
-
-	ast_audiohook_detach_source(chan, mixmonitor_spy_type);
+		struct mixmonitor_ds *mixmonitor_ds = datastore->data;
+
+		ast_mutex_lock(&mixmonitor_ds->lock);
+
+		/* closing the filestream here guarantees the file is avaliable to the dialplan
+	 	 * after calling StopMixMonitor */

[... 5530 lines stripped ...]



More information about the asterisk-commits mailing list