]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure that a non-zero sample rate is returned for all formats.
authorMark Michelson <mmichelson@digium.com>
Mon, 6 Apr 2015 16:02:09 +0000 (16:02 +0000)
committerMark Michelson <mmichelson@digium.com>
Mon, 6 Apr 2015 16:02:09 +0000 (16:02 +0000)
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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434046 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/format.c

index b6661574e5e649b2df8f2c6cadf1fb9f0e3440fa..3e1ee866ec3b042358193022bf5a8b1b0eb938d1 100644 (file)
@@ -375,7 +375,7 @@ unsigned int ast_format_get_minimum_bytes(const struct ast_format *format)
 
 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)