aboutsummaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-09 20:55:20 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-09 20:55:20 +0000
commite9327276a1535aca7db221bc7786069e8c917fe4 (patch)
treed96f6883574407bc735fa7069399ce9665e1b681 /formats
parenta220a8ccbc17c0de3774764518d2ebabe2189747 (diff)
Merge rmarchev's vox fixes (bug #1812)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3183 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats')
-rwxr-xr-xformats/format_vox.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 095332a51..92f4f4e56 100755
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -167,17 +167,36 @@ static char *vox_getcomment(struct ast_filestream *s)
static int vox_seek(struct ast_filestream *fs, long sample_offset, int whence)
{
- return -1;
+ off_t offset=0,min,cur,max,distance;
+
+ min = 0;
+ cur = lseek(fs->fd, 0, SEEK_CUR);
+ max = lseek(fs->fd, 0, SEEK_END);
+ /* have to fudge to frame here, so not fully to sample */
+ distance = sample_offset/2;
+ if(whence == SEEK_SET)
+ offset = distance;
+ else if(whence == SEEK_CUR || whence == SEEK_FORCECUR)
+ offset = distance + cur;
+ else if(whence == SEEK_END)
+ offset = max - distance;
+ if (whence != SEEK_FORCECUR) {
+ offset = (offset > max)?max:offset;
+ offset = (offset < min)?min:offset;
+ }
+ return lseek(fs->fd, offset, SEEK_SET);
}
static int vox_trunc(struct ast_filestream *fs)
{
- return -1;
+ return ftruncate(fs->fd, lseek(fs->fd,0,SEEK_CUR));
}
static long vox_tell(struct ast_filestream *fs)
{
- return -1;
+ off_t offset;
+ offset = lseek(fs->fd, 0, SEEK_CUR);
+ return offset;
}
int load_module()