diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-22 21:14:55 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-22 21:14:55 +0000 |
commit | 9935bee8cf864b5a57787f8fd72d150ef89ce68b (patch) | |
tree | 9b131feb9104cf0ca54f6bbc52640ee0f0c1798e /formats | |
parent | 0f572d416bc6cd1ed82cb9493cd1d2daff48667f (diff) |
I thought I was going to be able to leave 1.4 alone, but that was not the case.
I ran into some problems with G.722 in 1.4, so I have merged in all of the fixes
in this area that I have made in trunk/1.6.0, and things are happy again.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114550 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats')
-rw-r--r-- | formats/format_pcm.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 6facfcdcc..7b186e602 100644 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -102,7 +102,10 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext) 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; } @@ -380,24 +383,31 @@ static int au_rewrite(struct ast_filestream *s, const char *comment) 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; + 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); } |