[asterisk-commits] russell: branch russell/ast_channel_ao2 r173895 - in /team/russell/ast_channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 6 05:25:56 CST 2009


Author: russell
Date: Fri Feb  6 05:25:55 2009
New Revision: 173895

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=173895
Log:
Convert app_senddtmf and res_monitor

Modified:
    team/russell/ast_channel_ao2/apps/app_senddtmf.c
    team/russell/ast_channel_ao2/res/res_monitor.c

Modified: team/russell/ast_channel_ao2/apps/app_senddtmf.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/apps/app_senddtmf.c?view=diff&rev=173895&r1=173894&r2=173895
==============================================================================
--- team/russell/ast_channel_ao2/apps/app_senddtmf.c (original)
+++ team/russell/ast_channel_ao2/apps/app_senddtmf.c Fri Feb  6 05:25:55 2009
@@ -100,21 +100,23 @@
 {
 	const char *channel = astman_get_header(m, "Channel");
 	const char *digit = astman_get_header(m, "Digit");
-	struct ast_channel *chan = ast_get_channel_by_name_locked(channel);
+	struct ast_channel *chan;
 	
-	if (!chan) {
+	if (!(chan = ast_channel_get_by_name(channel))) {
 		astman_send_error(s, m, "Channel not specified");
 		return 0;
 	}
+
 	if (!digit) {
 		astman_send_error(s, m, "No digit specified");
-		ast_channel_unlock(chan);
+		chan = ast_channel_unref(chan);
 		return 0;
 	}
 
 	ast_senddigit(chan, *digit, 0);
 
-	ast_channel_unlock(chan);
+	chan = ast_channel_unref(chan);
+
 	astman_send_ack(s, m, "DTMF successfully queued");
 	
 	return 0;

Modified: team/russell/ast_channel_ao2/res/res_monitor.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/res/res_monitor.c?view=diff&rev=173895&r1=173894&r2=173895
==============================================================================
--- team/russell/ast_channel_ao2/res/res_monitor.c (original)
+++ team/russell/ast_channel_ao2/res/res_monitor.c Fri Feb  6 05:25:55 2009
@@ -579,17 +579,20 @@
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
-	c = ast_get_channel_by_name_locked(name);
-	if (!c) {
+
+	if (!(c = ast_channel_get_by_name(name))) {
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
+
+	ast_channel_lock(c);
 
 	if (ast_strlen_zero(fname)) {
 		/* No filename base specified, default to channel name as per CLI */		
 		if (!(fname = ast_strdup(c->name))) {
 			astman_send_error(s, m, "Could not start monitoring channel");
 			ast_channel_unlock(c);
+			c = ast_channel_unref(c);
 			return 0;
 		}
 		/* Channels have the format technology/channel_name - have to replace that /  */
@@ -601,6 +604,7 @@
 		if (ast_monitor_change_fname(c, fname, 1)) {
 			astman_send_error(s, m, "Could not start monitoring channel");
 			ast_channel_unlock(c);
+			c = ast_channel_unref(c);
 			return 0;
 		}
 	}
@@ -610,7 +614,10 @@
 	}
 
 	ast_channel_unlock(c);
+	c = ast_channel_unref(c);
+
 	astman_send_ack(s, m, "Started monitoring channel");
+
 	return 0;
 }
 
@@ -625,22 +632,31 @@
 	struct ast_channel *c = NULL;
 	const char *name = astman_get_header(m, "Channel");
 	int res;
+
 	if (ast_strlen_zero(name)) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
-	c = ast_get_channel_by_name_locked(name);
-	if (!c) {
+
+	if (!(c = ast_channel_get_by_name(name))) {
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
+
+	ast_channel_lock(c);
+
 	res = ast_monitor_stop(c, 1);
+
 	ast_channel_unlock(c);
+	c = ast_channel_unref(c);
+
 	if (res) {
 		astman_send_error(s, m, "Could not stop monitoring channel");
 		return 0;
 	}
+
 	astman_send_ack(s, m, "Stopped monitoring channel");
+
 	return 0;
 }
 
@@ -658,26 +674,36 @@
 	struct ast_channel *c = NULL;
 	const char *name = astman_get_header(m, "Channel");
 	const char *fname = astman_get_header(m, "File");
+
 	if (ast_strlen_zero(name)) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
+
 	if (ast_strlen_zero(fname)) {
 		astman_send_error(s, m, "No filename specified");
 		return 0;
 	}
-	c = ast_get_channel_by_name_locked(name);
-	if (!c) {
+
+	if (!(c = ast_channel_get_by_name(name))) {
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
+
+	ast_channel_lock(c);
+
 	if (ast_monitor_change_fname(c, fname, 1)) {
+		ast_channel_unlock(c);
+		c = ast_channel_unref(c);
 		astman_send_error(s, m, "Could not change monitored filename of channel");
-		ast_channel_unlock(c);
-		return 0;
-	}
+		return 0;
+	}
+	
 	ast_channel_unlock(c);
+	c = ast_channel_unref(c);
+
 	astman_send_ack(s, m, "Changed monitor filename");
+
 	return 0;
 }
 
@@ -703,19 +729,24 @@
 		return -1;
 	}
 	
-	c = ast_get_channel_by_name_locked(name);
-	if (!c) {
+	if (!(c = ast_channel_get_by_name(name))) {
 		astman_send_error(s, m, "No such channel");
 		return -1;
 	}
 
-	if (action == MONITOR_ACTION_PAUSE)
+	ast_channel_lock(c);
+
+	if (action == MONITOR_ACTION_PAUSE) {
 		ast_monitor_pause(c);
-	else
+	} else {
 		ast_monitor_unpause(c);
+	}
 	
 	ast_channel_unlock(c);
+	c = ast_channel_unref(c);
+
 	astman_send_ack(s, m, (action == MONITOR_ACTION_PAUSE ? "Paused monitoring of the channel" : "Unpaused monitoring of the channel"));
+
 	return 0;	
 }
 




More information about the asterisk-commits mailing list