[asterisk-commits] mmichelson: trunk r434047 - in /trunk: ./ main/format.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 6 11:02:29 CDT 2015


Author: mmichelson
Date: Mon Apr  6 11:02:28 2015
New Revision: 434047

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=434047
Log:
Ensure that a non-zero sample rate is returned for all formats.

Versions of Asterisk prior to 12 defaulted to 8000 as a sample rate
if one was not provided by a format. In Asterisk 13, this was removed.
The result was that some calculations which involve dividing by the
sample rate resulted in dividing by 0. The fix being put in place
here is to have the same default fallback that was present in previous
versions of Asterisk.

Asterisk-24914 #close
Reported by Marcello Ceschia
........

Merged revisions 434046 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/main/format.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/main/format.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/format.c?view=diff&rev=434047&r1=434046&r2=434047
==============================================================================
--- trunk/main/format.c (original)
+++ trunk/main/format.c Mon Apr  6 11:02:28 2015
@@ -375,7 +375,7 @@
 
 unsigned int ast_format_get_sample_rate(const struct ast_format *format)
 {
-	return format->codec->sample_rate;
+	return format->codec->sample_rate ?: 8000;
 }
 
 unsigned int ast_format_determine_length(const struct ast_format *format, unsigned int samples)




More information about the asterisk-commits mailing list