[asterisk-commits] rmudgett: branch group/media_formats-reviewed-trunk r418609 - /team/group/med...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 14 10:33:46 CDT 2014


Author: rmudgett
Date: Mon Jul 14 10:33:42 2014
New Revision: 418609

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418609
Log:
translate.c: Reduce the number of codec refs in the log when the translation matrix is rebuilt.

There is no need to ref/unref codecs when the debug level is not high
enough to output the debug message.  This substantially reduces the refs
log for codecs.

Review: https://reviewboard.asterisk.org/r/3774/

Modified:
    team/group/media_formats-reviewed-trunk/main/translate.c

Modified: team/group/media_formats-reviewed-trunk/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/translate.c?view=diff&rev=418609&r1=418608&r2=418609
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/translate.c (original)
+++ team/group/media_formats-reviewed-trunk/main/translate.c Mon Jul 14 10:33:42 2014
@@ -789,20 +789,25 @@
 					/* if no step already exists between x and z OR the new cost of using the intermediate
 					 * step is cheaper, use this step. */
 					if (!matrix_get(x, z)->step || (newtablecost < matrix_get(x, z)->table_cost)) {
-						struct ast_codec *x_codec = index2codec(x);
-						struct ast_codec *y_codec = index2codec(y);
-						struct ast_codec *z_codec = index2codec(z);
-
 						matrix_get(x, z)->step = matrix_get(x, y)->step;
 						matrix_get(x, z)->table_cost = newtablecost;
 						matrix_get(x, z)->multistep = 1;
 						changed++;
-						ast_debug(10, "Discovered %u cost path from %s to %s, via %s\n",
-							  matrix_get(x, z)->table_cost, x_codec->name,
-							  y_codec->name, z_codec->name);
-						ao2_ref(x_codec, -1);
-						ao2_ref(y_codec, -1);
-						ao2_ref(z_codec, -1);
+
+						if (DEBUG_ATLEAST(10)) {
+							struct ast_codec *x_codec = index2codec(x);
+							struct ast_codec *y_codec = index2codec(y);
+							struct ast_codec *z_codec = index2codec(z);
+
+							ast_log(LOG_DEBUG,
+								"Discovered %u cost path from %s to %s, via %s\n",
+								matrix_get(x, z)->table_cost, x_codec->name,
+								y_codec->name, z_codec->name);
+
+							ao2_ref(x_codec, -1);
+							ao2_ref(y_codec, -1);
+							ao2_ref(z_codec, -1);
+						}
 					}
 				}
 			}
@@ -1377,8 +1382,8 @@
 	   destination format. */
 	for (index = 0; (src_index >= 0) && index < cur_max_index; index++) {
 		struct ast_codec *codec = index2codec(index);
-		RAII_VAR(struct ast_format *, fmt,
-			 ast_format_create(codec), ao2_cleanup);
+		RAII_VAR(struct ast_format *, fmt, ast_format_create(codec), ao2_cleanup);
+
 		ao2_ref(codec, -1);
 
 		if (ast_format_get_type(fmt) != type) {
@@ -1423,7 +1428,7 @@
 
 		/* We give preference to a joint format structure if possible */
 		if ((cur_src = ast_format_cap_get_compatible_format(src, cur_dest))) {
-				ast_format_cap_append(result, cur_src, 0);
+			ast_format_cap_append(result, cur_src, 0);
 			ao2_ref(cur_src, -1);
 		} else {
 			/* Otherwise we just use the destination format */




More information about the asterisk-commits mailing list