mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
Properly implement using zaptel for timing of file playback
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
21
file.c
21
file.c
@@ -508,16 +508,26 @@ static int ast_readaudio_callback(void *data)
|
||||
if (ast_write(s->owner, fr)) {
|
||||
ast_log(LOG_WARNING, "Failed to write frame\n");
|
||||
s->owner->streamid = -1;
|
||||
#ifdef ZAPTEL_OPTIMIZATIONS
|
||||
ast_settimeout(s->owner, 0, NULL, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* Stream has finished */
|
||||
s->owner->streamid = -1;
|
||||
#ifdef ZAPTEL_OPTIMIZATIONS
|
||||
ast_settimeout(s->owner, 0, NULL, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (whennext != s->lasttimeout) {
|
||||
#ifdef ZAPTEL_OPTIMIZATIONS
|
||||
ast_settimeout(s->owner, whennext, ast_readaudio_callback, s);
|
||||
#else
|
||||
s->owner->streamid = ast_sched_add(s->owner->sched, whennext/8, ast_readaudio_callback, s);
|
||||
#endif
|
||||
s->lasttimeout = whennext;
|
||||
return 0;
|
||||
}
|
||||
@@ -606,6 +616,9 @@ int ast_closestream(struct ast_filestream *f)
|
||||
if (f->owner->streamid > -1)
|
||||
ast_sched_del(f->owner->sched, f->owner->streamid);
|
||||
f->owner->streamid = -1;
|
||||
#ifdef ZAPTEL_OPTIMIZATIONS
|
||||
ast_settimeout(f->owner, 0, NULL, NULL);
|
||||
#endif
|
||||
} else {
|
||||
f->owner->vstream = NULL;
|
||||
if (f->owner->vstreamid > -1)
|
||||
@@ -766,15 +779,15 @@ char ast_waitstream(struct ast_channel *c, char *breakon)
|
||||
struct ast_frame *fr;
|
||||
while(c->stream) {
|
||||
res = ast_sched_wait(c->sched);
|
||||
if (res < 0) {
|
||||
if ((res < 0) && !c->timingfunc) {
|
||||
if (c->stream)
|
||||
ast_closestream(c->stream);
|
||||
if (c->vstream)
|
||||
ast_closestream(c->vstream);
|
||||
break;
|
||||
}
|
||||
/* Setup timeout if supported */
|
||||
ast_settimeout(c, res);
|
||||
if (res < 0)
|
||||
res = 1000;
|
||||
res = ast_waitfor(c, res);
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
|
||||
@@ -832,7 +845,6 @@ char ast_waitstream_fr(struct ast_channel *c, char *breakon, char *forward, char
|
||||
ast_closestream(c->vstream);
|
||||
break;
|
||||
}
|
||||
ast_settimeout(c, res);
|
||||
res = ast_waitfor(c, res);
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
|
||||
@@ -899,7 +911,6 @@ char ast_waitstream_full(struct ast_channel *c, char *breakon, int audiofd, int
|
||||
ast_closestream(c->vstream);
|
||||
break;
|
||||
}
|
||||
ast_settimeout(c, ms);
|
||||
rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
|
||||
if (!rchan && (outfd < 0) && (ms)) {
|
||||
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
|
||||
|
Reference in New Issue
Block a user