[asterisk-commits] trunk r21207 - in /trunk: include/asterisk/translate.h translate.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Apr 18 14:39:21 MST 2006


Author: kpfleming
Date: Tue Apr 18 16:39:20 2006
New Revision: 21207

URL: http://svn.digium.com/view/asterisk?rev=21207&view=rev
Log:
correct array index calculation (thanks mtaht3!)
update header file comments to reflect new usage of structure field

Modified:
    trunk/include/asterisk/translate.h
    trunk/translate.c

Modified: trunk/include/asterisk/translate.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/translate.h?rev=21207&r1=21206&r2=21207&view=diff
==============================================================================
--- trunk/include/asterisk/translate.h (original)
+++ trunk/include/asterisk/translate.h Tue Apr 18 16:39:20 2006
@@ -65,8 +65,10 @@
  */
 struct ast_translator {
 	const char name[80];		/*! Name of translator */
-	int srcfmt;			/*! Source format (note: bit position) */
-	int dstfmt;			/*! Destination format (note: bit position) */
+	int srcfmt;			/*! Source format (note: bit position,
+					  converted to index during registration) */
+	int dstfmt;			/*! Destination format (note: bit position,
+					  converted to index during registration) */
 
 	/*! initialize private data associated with the translator */
 	void *(*newpvt)(struct ast_trans_pvt *);

Modified: trunk/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/translate.c?rev=21207&r1=21206&r2=21207&view=diff
==============================================================================
--- trunk/translate.c (original)
+++ trunk/translate.c Tue Apr 18 16:39:20 2006
@@ -400,6 +400,7 @@
 		ast_log(LOG_DEBUG, "Resetting translation matrix\n");
 
 	bzero(tr_matrix, sizeof(tr_matrix));
+
 	/* first, compute all direct costs */
 	AST_LIST_TRAVERSE(&translators, t, list) {
 		x = t->srcfmt;
@@ -413,6 +414,7 @@
 			tr_matrix[x][z].cost = t->cost;
 		}
 	}
+
 	/*
 	 * For each triple x, y, z of distinct formats, check if there is
 	 * a path from x to z through y which is cheaper than what is
@@ -656,6 +658,9 @@
 
 unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
 {
+	/* convert bitwise format numbers into array indices */
+	src = powerof(src);
+	dest = powerof(dest);
 	if (!tr_matrix[src][dest].step)
 		return -1;
 	else



More information about the asterisk-commits mailing list