diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-02-06 22:11:43 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-02-06 22:11:43 +0000 |
commit | 8b1f06abb435a2aa00d7b5d1e8dd1588bf895483 (patch) | |
tree | 8220ad163713cb38240eb18c24be25aa88b28865 /formats/format_pcm.c | |
parent | 12b57158d66873fd353d3ae66662e205bd96debb (diff) |
Version 0.3.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@608 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'formats/format_pcm.c')
-rwxr-xr-x | formats/format_pcm.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 8576f6995..28daed68f 100755 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -149,6 +149,7 @@ static void pcm_close(struct ast_filestream *s) ast_log(LOG_WARNING, "Freeing a filestream we don't seem to own\n"); close(s->fd); free(s); + s = NULL; } static int ast_read_callback(void *data) @@ -171,9 +172,9 @@ static int ast_read_callback(void *data) s->owner->streamid = -1; return 0; } - s->fr.timelen = res / 8; + s->fr.samples = res; s->fr.datalen = res; - delay = s->fr.timelen; + delay = s->fr.samples/8; /* Lastly, process the frame */ if (ast_write(s->owner, &s->fr)) { ast_log(LOG_WARNING, "Failed to write frame\n"); @@ -215,6 +216,11 @@ static int pcm_apply(struct ast_channel *c, struct ast_filestream *s) { /* Select our owner for this stream, and get the ball rolling. */ s->owner = c; + return 0; +} + +static int pcm_play(struct ast_filestream *s) +{ ast_read_callback(s); return 0; } @@ -237,6 +243,36 @@ static int pcm_write(struct ast_filestream *fs, struct ast_frame *f) return 0; } +static int pcm_seek(struct ast_filestream *fs, long sample_offset, int whence) +{ + off_t offset,min,cur,max; + + min = 0; + cur = lseek(fs->fd, 0, SEEK_CUR); + max = lseek(fs->fd, 0, SEEK_END); + if(whence == SEEK_SET) + offset = sample_offset; + if(whence == SEEK_CUR) + offset = sample_offset + cur; + if(whence == SEEK_END) + offset = max - sample_offset; + offset = (offset > max)?max:offset; + offset = (offset < min)?min:offset; + return lseek(fs->fd, offset, SEEK_SET); +} + +static int pcm_trunc(struct ast_filestream *fs) +{ + return ftruncate(fs->fd, lseek(fs->fd,0,SEEK_CUR)); +} + +static long pcm_tell(struct ast_filestream *fs) +{ + off_t offset; + offset = lseek(fs->fd, 0, SEEK_CUR); + return offset; +} + static char *pcm_getcomment(struct ast_filestream *s) { return NULL; @@ -248,7 +284,11 @@ int load_module() pcm_open, pcm_rewrite, pcm_apply, + pcm_play, pcm_write, + pcm_seek, + pcm_trunc, + pcm_tell, pcm_read, pcm_close, pcm_getcomment); |