[asterisk-commits] twilson: trunk r287834 - in /trunk: ./ main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 20 23:39:33 CDT 2010


Author: twilson
Date: Mon Sep 20 23:39:30 2010
New Revision: 287834

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287834
Log:
Merged revisions 287833 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r287833 | twilson | 2010-09-20 23:37:44 -0500 (Mon, 20 Sep 2010) | 3 lines
  
  Don't generate connected line buffer twice for comparison
........

Modified:
    trunk/   (props changed)
    trunk/main/channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=287834&r1=287833&r2=287834
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Mon Sep 20 23:39:30 2010
@@ -8227,44 +8227,21 @@
 	return 0;
 }
 
-/*! \brief Determine if two ast_party_connected_line structures differ
- *
- * \param c1 One of the structs to compare
- * \param c2 The other struct to compare
- * \retval 0 No difference or one of the structs is NULL
- * \retval non-zero The structs differ
- */
-static int connected_line_differ(const struct ast_party_connected_line *c1, const struct ast_party_connected_line *c2)
-{
-	unsigned char buf1[1024] = { 0, };
-	unsigned char buf2[sizeof(buf1)] = { 0, };
-
-	if (!c1 || !c2) {
-		return 0;
-	}
-
-	ast_connected_line_build_data(buf1, sizeof(buf1), c1, NULL);
-	ast_connected_line_build_data(buf2, sizeof(buf2), c2, NULL);
-
-	return memcmp(buf1, buf2, sizeof(buf1));
-}
-
 void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 {
-	unsigned char data[1024];	/* This should be large enough */
+	unsigned char data[1024] = { 0, };	/* This should be large enough */
+	unsigned char data2[sizeof(data)] = { 0, };
 	size_t datalen;
-
-	if (!connected_line_differ(&chan->connected, connected)) {
-		ast_debug(1, "No change, so ignoring update\n");
-		return;
-	}
 
 	datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
 	if (datalen == (size_t) -1) {
 		return;
 	}
 
-	ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
+	/* Only send an update if the connected line info is different or the channels info is suspect */
+	if (ast_connected_line_build_data(data2, sizeof(data2), &chan->connected, update) == -1 || memcmp(data, data2, sizeof(data))) {
+		ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
+	}
 }
 
 void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)




More information about the asterisk-commits mailing list