diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-07-22 13:18:59 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-07-22 13:19:00 -0500 |
commit | 43173f073c6055f5b46c8e0b7f86e455c7f99336 (patch) | |
tree | d9b50cb010864e0ed02efe8a757f0cda0b859272 /main | |
parent | 0b7148e262c729f9cf07f140c27f04e647b80ef2 (diff) | |
parent | e5fe8d40c840ea806da239a868eeeae054e28308 (diff) |
Merge "audiohook: Read the correct number of samples based on audiohook format."
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index 3e233fa2a..641264a98 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -377,6 +377,16 @@ static struct ast_frame *audiohook_read_frame_helper(struct ast_audiohook *audio audiohook_set_internal_rate(audiohook, ast_format_get_sample_rate(format), 1); } + /* If the sample rate of the requested format differs from that of the underlying audiohook + * sample rate determine how many samples we actually need to get from the audiohook. This + * needs to occur as the signed linear factory stores them at the rate of the audiohook. + * We do this by determining the duration of audio they've requested and then determining + * how many samples that would be in the audiohook format. + */ + if (ast_format_get_sample_rate(format) != audiohook->hook_internal_samp_rate) { + samples = (audiohook->hook_internal_samp_rate / 1000) * (samples / (ast_format_get_sample_rate(format) / 1000)); + } + if (!(read_frame = (direction == AST_AUDIOHOOK_DIRECTION_BOTH ? audiohook_read_frame_both(audiohook, samples, read_reference, write_reference) : audiohook_read_frame_single(audiohook, samples, direction)))) { |