[asterisk-commits] russell: branch russell/chan_console r81423 - /team/russell/chan_console/chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 1 00:02:14 CDT 2007


Author: russell
Date: Sat Sep  1 00:02:11 2007
New Revision: 81423

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81423
Log:
Make a minor optimization to handling input from the audio lib.  Only write
to each part of the read_buf once by not zeroing out the part of the buffer
where the audio goes unless the channel is actually muted.

Modified:
    team/russell/chan_console/channels/chan_console.c

Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=81423&r1=81422&r2=81423
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Sat Sep  1 00:02:11 2007
@@ -568,6 +568,7 @@
 	if (l > 0)
 		pvt->sampsent = l_sampsent;	/* update status */
 }
+
 static int handle_output(struct console_pvt *pvt, void *output, unsigned long frame_count)
 {
 	unsigned int src = 0;
@@ -626,15 +627,21 @@
 	unsigned int count = 0;
 
 	memset(fr, 0, sizeof(*fr));
-	memset(pvt->read_buf, 0, frame_count * 2 + AST_FRIENDLY_OFFSET);
+	memset(pvt->read_buf, 0, AST_FRIENDLY_OFFSET);
 	fr->data = pvt->read_buf + AST_FRIENDLY_OFFSET;
 	fr->offset = AST_FRIENDLY_OFFSET;
 	fr->frametype = AST_FRAME_VOICE;
 	fr->subclass = AST_FORMAT_SLINEAR;
 	fr->samples = frame_count;
 	fr->datalen = frame_count * 2;
-	if (!pvt->muted) /* If muted, just leave the data all zeros */
-		memcpy(fr->data, input, frame_count * 2);
+	if (pvt->muted) {
+		memcpy(fr->data, input, 
+			MIN(sizeof(pvt->read_buf) - AST_FRIENDLY_OFFSET, frame_count * 2) );
+	} else {
+		/* If muted, just leave the data all zeros */
+		memset(pvt->read_buf + AST_FRIENDLY_OFFSET, 0, 
+			sizeof(pvt->read_buf) - AST_FRIENDLY_OFFSET);
+	}
 
 	/* If the channel is in the process of being hung up, then it will be
 	 * locked while calling the console_hangup callback, and that could be




More information about the asterisk-commits mailing list