[asterisk-commits] russell: branch 1.6.0 r110269 - in /branches/1.6.0: ./ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 20 12:41:45 CDT 2008
Author: russell
Date: Thu Mar 20 12:41:45 2008
New Revision: 110269
URL: http://svn.digium.com/view/asterisk?view=rev&rev=110269
Log:
Merged revisions 110268 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r110268 | russell | 2008-03-20 12:41:22 -0500 (Thu, 20 Mar 2008) | 27 lines
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.
........
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/main/channel.c
branches/1.6.0/res/res_musiconhold.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=110269&r1=110268&r2=110269
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Thu Mar 20 12:41:45 2008
@@ -1724,7 +1724,7 @@
if (!tmp || !generate)
return 0;
- res = generate(chan, tmp, 0, 160);
+ res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50);
chan->generatordata = tmp;
@@ -2256,6 +2256,7 @@
if (chan->generatordata && !ast_internal_timing_enabled(chan)) {
void *tmp = chan->generatordata;
int res;
+ int samples;
if (chan->timingfunc) {
if (option_debug > 1)
@@ -2264,7 +2265,15 @@
}
chan->generatordata = NULL; /* reset, to let writes go through */
- res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
+
+ if (f->subclass != chan->writeformat) {
+ float factor;
+ factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass));
+ samples = (int) ( ((float) f->samples) * factor );
+ } else {
+ samples = f->samples;
+ }
+ res = chan->generator->generate(chan, tmp, f->datalen, samples);
chan->generatordata = tmp;
if (res) {
if (option_debug > 1)
Modified: branches/1.6.0/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/res/res_musiconhold.c?view=diff&rev=110269&r1=110268&r2=110269
==============================================================================
--- branches/1.6.0/res/res_musiconhold.c (original)
+++ branches/1.6.0/res/res_musiconhold.c Thu Mar 20 12:41:45 2008
@@ -312,8 +312,8 @@
while (state->sample_queue > 0) {
if ((f = moh_files_readframe(chan))) {
state->samples += f->samples;
+ state->sample_queue -= f->samples;
res = ast_write(chan, f);
- state->sample_queue -= f->samples;
ast_frfree(f);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
More information about the asterisk-commits
mailing list