diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-04-06 16:02:28 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2015-04-06 16:02:28 +0000 |
commit | edf9da436554973fe830fedea3ff2d059e8883e5 (patch) | |
tree | 5ad749a40b74ebd5ce96cb648eb457f1c6a11444 /main/format.c | |
parent | ffd7319df337a2b99f4df4422b27d8aee07697af (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434047 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/format.c')
-rw-r--r-- | main/format.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/main/format.c b/main/format.c index b6661574e..3e1ee866e 100644 --- a/main/format.c +++ b/main/format.c @@ -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) |