[asterisk-commits] [svn-commits] russell: branch russell/g722-sillyness r106494 - in /team/russell/g722-sillyn...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 6 16:28:25 CST 2008
Author: russell
Date: Thu Mar 6 16:28:25 2008
New Revision: 106494
URL: http://svn.digium.com/view/asterisk?view=rev&rev=106494
Log:
Fix up some places where numbers of samples were improperly generated and interpreted
for G.722. This explains why recording to wav and then playing it back was broken,
but converting g.722 to wav via the "file convert" CLI command worked. That was because
the frames coming in from RTP had the correct numbers of samples in the frames.
However, reading from the g722 file stream had the incorrect number of samples. I
fixed this, but that unfortunately means that both methods are now equally broken.
Next, figure out where playing back a non-g722 format to a g722 phone is broken.
(issue #12130)
Modified:
team/russell/g722-sillyness/formats/format_pcm.c
team/russell/g722-sillyness/main/file.c
Modified: team/russell/g722-sillyness/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/team/russell/g722-sillyness/formats/format_pcm.c?view=diff&rev=106494&r1=106493&r2=106494
==============================================================================
--- team/russell/g722-sillyness/formats/format_pcm.c (original)
+++ team/russell/g722-sillyness/formats/format_pcm.c Thu Mar 6 16:28:25 2008
@@ -89,7 +89,10 @@
return NULL;
}
s->fr.datalen = res;
- *whennext = s->fr.samples = res;
+ if (s->fmt->format == AST_FORMAT_G722)
+ *whennext = s->fr.samples = res * 2;
+ else
+ *whennext = s->fr.samples = res;
return &s->fr;
}
@@ -367,24 +370,32 @@
static int au_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
{
off_t min, max, cur;
- long offset = 0, samples;
-
- samples = sample_offset;
+ long offset = 0, bytes;
+
+ if (fs->fmt->format == AST_FORMAT_G722)
+ bytes = sample_offset / 2;
+ else
+ bytes = sample_offset;
+
min = AU_HEADER_SIZE;
cur = ftello(fs->f);
fseek(fs->f, 0, SEEK_END);
max = ftello(fs->f);
+
if (whence == SEEK_SET)
- offset = samples + min;
+ offset = bytes + min;
else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
- offset = samples + cur;
+ offset = bytes + cur;
else if (whence == SEEK_END)
- offset = max - samples;
- if (whence != SEEK_FORCECUR) {
+ offset = max - bytes;
+
+ if (whence != SEEK_FORCECUR) {
offset = (offset > max) ? max : offset;
}
+
/* always protect the header space. */
offset = (offset < min) ? min : offset;
+
return fseeko(fs->f, offset, SEEK_SET);
}
Modified: team/russell/g722-sillyness/main/file.c
URL: http://svn.digium.com/view/asterisk/team/russell/g722-sillyness/main/file.c?view=diff&rev=106494&r1=106493&r2=106494
==============================================================================
--- team/russell/g722-sillyness/main/file.c (original)
+++ team/russell/g722-sillyness/main/file.c Thu Mar 6 16:28:25 2008
@@ -669,7 +669,8 @@
ast_settimeout(s->owner, whennext, ast_fsread_audio, s);
else
#endif
- s->owner->streamid = ast_sched_add(s->owner->sched, whennext / 8, ast_fsread_audio, s);
+ s->owner->streamid = ast_sched_add(s->owner->sched,
+ whennext / (ast_format_rate(s->fmt->format) / 1000), ast_fsread_audio, s);
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
}
@@ -713,7 +714,8 @@
}
if (whennext != s->lasttimeout) {
- s->owner->vstreamid = ast_sched_add(s->owner->sched, whennext / 8,
+ s->owner->vstreamid = ast_sched_add(s->owner->sched,
+ whennext / (ast_format_rate(s->fmt->format) / 1000),
ast_fsread_video, s);
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits
More information about the asterisk-commits
mailing list