aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-20 17:41:22 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-20 17:41:22 +0000
commit72a7d745691df2ae66c481ead21f443a45161461 (patch)
tree7fecfcc8870ecf1fa1778dadbf0b5a542a6db154 /res/res_musiconhold.c
parentb787b1b3bfb49899414809d56225a417222c17ac (diff)
Add some fixes that I made in regards to wideband codec handling to get
G.722 music on hold working for me. (issue #12164, reported by milazzo and jsmith, patches by me) res/res_musiconhold.c: - I moved a single line so that the sample queue update happened before ast_write(). The reason that this was a bug is that the G.722 frame originally says it has 320 samples in it (which is correct). However, when the frame is written to a channel that uses RTP, main/rtp.c modifies the frame to cut the number of samples in half before it sends it on the wire. This is to account for the stupid incorrect G.722 spec that makes it so we have to lie about the number of samples with RTP. I should probably go and re-work the RTP code so it doesn't modify the frame so that a bug like this won't happen in the future. However, this change to MOH is harmless. main/channel.c: - I made two fixes in regards to generator timing. Generators use samples for timing. However, this code assumed 8 kHz samples. In one case, it was a hard coded 160 samples, that is now written as the sample rate / 50. The other place was dealing with timing a generator based on frames coming from the other direction. However, that would have only worked if the sample rates for the formats in both directions were the same. The code now takes into account that the sample rates may differ, and scales the generator samples accordingly. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@110268 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 1b44b3dfd..e7044eff9 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -312,8 +312,8 @@ static int moh_files_generator(struct ast_channel *chan, void *data, int len, in
while (state->sample_queue > 0) {
if ((f = moh_files_readframe(chan))) {
state->samples += f->samples;
- res = ast_write(chan, f);
state->sample_queue -= f->samples;
+ res = ast_write(chan, f);
ast_frfree(f);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));