[asterisk-commits] russell: trunk r296085 - in /trunk: ./ main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 24 14:24:42 CST 2010


Author: russell
Date: Wed Nov 24 14:24:38 2010
New Revision: 296085

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

................
  r296084 | russell | 2010-11-24 14:23:46 -0600 (Wed, 24 Nov 2010) | 26 lines
  
  Merged revisions 296083 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r296083 | russell | 2010-11-24 14:23:11 -0600 (Wed, 24 Nov 2010) | 19 lines
    
    Merged revisions 296082 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r296082 | russell | 2010-11-24 14:22:32 -0600 (Wed, 24 Nov 2010) | 12 lines
      
      Fix false reporting of an error by set_format().
      
      In the case that the native format was able to be changed to match the
      new requested format, the code proceeded to attempt to build a translation
      path, anyway.  The result would be NULL, since no translation path is
      necessary and resulted in this function thinking an error has occurred.
      This case is now specifically caught and no attempt to build a translation
      path is attempted.
      
      Thanks to our automated tests and bamboo.asterisk.org for catching this problem
      and making a whole lot of noise when things started failing.  :-)
    ........
  ................
................

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=296085&r1=296084&r2=296085
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed Nov 24 14:24:38 2010
@@ -4994,13 +4994,23 @@
 	if (*trans)
 		ast_translator_free_path(*trans);
 	/* Build a translation path from the raw format to the desired format */
-	if (!direction)
-		/* reading */
-		*trans = ast_translator_build_path(*format, *rawformat);
-	else
-		/* writing */
-		*trans = ast_translator_build_path(*rawformat, *format);
-	res = *trans ? 0 : -1;
+	if (*format == *rawformat) {
+		/*
+		 * If we were able to swap the native format to the format that
+		 * has been requested, then there is no need to try to build
+		 * a translation path.
+		 */
+		res = 0;
+	} else {
+		if (!direction) {
+			/* reading */
+			*trans = ast_translator_build_path(*format, *rawformat);
+		} else {
+			/* writing */
+			*trans = ast_translator_build_path(*rawformat, *format);
+		}
+		res = *trans ? 0 : -1;
+	}
 	ast_channel_unlock(chan);
 	ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
 		direction ? "write" : "read", ast_getformatname(fmt));




More information about the asterisk-commits mailing list