diff options
author | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-31 19:00:40 +0000 |
---|---|---|
committer | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-31 19:00:40 +0000 |
commit | b08d26f4ff632e59a829d806d325f70a6acf7b83 (patch) | |
tree | 7569bb92299eb808c39de847a6e382eadee68ff0 /apps | |
parent | 20cd57249ce34509445ac99a97a8544ee0dedc76 (diff) |
more optimizations
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5318 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_chanspy.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 065578e73..a1bf6563a 100755 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -201,7 +201,6 @@ static void ast_flush_spy_queue(struct ast_channel_spy *spy) ast_mutex_unlock(&spy->lock); } - static int spy_generate(struct ast_channel *chan, void *data, int len, int samples) { struct ast_frame *f, *f0, *f1; @@ -311,7 +310,7 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl csth->frame.data = csth->buf; ast_write(chan, &csth->frame); - + if (f0) { ast_frfree(f0); } @@ -395,6 +394,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int int running = 1, res = 0, x = 0; char inp[24]; char *name=NULL; + struct ast_frame *f; if (chan && !ast_check_hangup(chan) && spyee && !ast_check_hangup(spyee)) { memset(inp, 0, sizeof(inp)); @@ -413,9 +413,22 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int start_spying(spyee, chan, &csth.spy); ast_activate_generator(chan, &spygen, &csth); - while(csth.spy.status == CHANSPY_RUNNING && chan && !ast_check_hangup(chan) && spyee && !ast_check_hangup(spyee) && running == 1) { - res = ast_waitfordigit(chan, 100); - + while(csth.spy.status == CHANSPY_RUNNING && + chan && !ast_check_hangup(chan) && + spyee && + !ast_check_hangup(spyee) + && running == 1 && + (res = ast_waitfor(chan, -1) > -1)) { + if ((f = ast_read(chan))) { + res = 0; + if(f->frametype == AST_FRAME_DTMF) { + res = f->subclass; + } + ast_frfree(f); + if(!res) { + continue; + } + } if (x == sizeof(inp)) { x = 0; } |