[svn-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r300162 - in /team/dvossel/f...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jan 3 21:37:49 UTC 2011


Author: dvossel
Date: Mon Jan  3 15:37:46 2011
New Revision: 300162

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300162
Log:
Codec pref size is no longer based on the size of the format_t bit field.

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h
    team/dvossel/fixtheworld_phase1_step3/main/format_pref.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h?view=diff&rev=300162&r1=300161&r2=300162
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h Mon Jan  3 15:37:46 2011
@@ -25,9 +25,16 @@
 #define _AST_FORMATPREF_H_
 
 #include "asterisk/frame_defs.h"
+
+#define AST_CODEC_PREF_SIZE 64
 struct ast_codec_pref {
-	char order[sizeof(format_t) * 8];
-	char framing[sizeof(format_t) * 8];
+	/*! This array represents the each format in the pref list */
+	/* TODO uncomment me when the switch over to ast_format takes place */
+	// struct ast_format[AST_CODEC_PREF_SIZE];
+	/*! This array represents the format id's index in the global format list. */
+	char order[AST_CODEC_PREF_SIZE];
+	/*! This array represents the format's framing size if present. */
+	char framing[AST_CODEC_PREF_SIZE];
 };
 
 /*! \page AudioCodecPref Audio Codec Preferences

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_pref.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_pref.c?view=diff&rev=300162&r1=300161&r2=300162
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_pref.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_pref.c Mon Jan  3 15:37:46 2011
@@ -27,7 +27,6 @@
 
 #include "asterisk/_private.h"
 #include "asterisk/version.h"
-#include "asterisk/format.h"
 #include "asterisk/frame.h"
 #include "asterisk/channel.h"
 #include "asterisk/utils.h"
@@ -37,6 +36,8 @@
 	int x, differential = (int) 'A', mem;
 	char *from, *to;
 
+	/* TODO re-evaluate this function.  It is using the order of the formats specified
+	 * in the global format list in a way that may not be safe. */
 	if (right) {
 		from = pref->order;
 		to = buf;
@@ -44,11 +45,11 @@
 	} else {
 		to = pref->order;
 		from = buf;
-		mem = sizeof(format_t) * 8;
+		mem = AST_CODEC_PREF_SIZE;
 	}
 
 	memset(to, 0, mem);
-	for (x = 0; x < sizeof(format_t) * 8; x++) {
+	for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
 		if (!from[x])
 			break;
 		to[x] = right ? (from[x] + differential) : (from[x] - differential);
@@ -66,7 +67,7 @@
 	total_len = size;
 	buf[0] = '(';
 	total_len--;
-	for (x = 0; x < sizeof(format_t) * 8; x++) {
+	for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
 		if (total_len <= 0)
 			break;
 		if (!(codec = ast_codec_pref_index(pref,x)))
@@ -78,7 +79,7 @@
 			strncat(buf, formatname, total_len - 1); /* safe */
 			total_len -= slen;
 		}
-		if (total_len && x < sizeof(format_t) * 8 - 1 && ast_codec_pref_index(pref, x + 1)) {
+		if (total_len && x < AST_CODEC_PREF_SIZE - 1 && ast_codec_pref_index(pref, x + 1)) {
 			strncat(buf, "|", total_len - 1); /* safe */
 			total_len--;
 		}
@@ -179,7 +180,7 @@
 		return;
 
 	/* Now find any existing occurrence, or the end */
-	for (x = 0; x < sizeof(format_t) * 8; x++) {
+	for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
 		if (!pref->order[x] || pref->order[x] == newindex)
 			break;
 	}




More information about the svn-commits mailing list