mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
Version 0.3.0 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@608 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user