summaryrefslogtreecommitdiff
path: root/res/res_agi.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-07-15 23:00:47 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-07-15 23:00:47 +0000
commit22b0f5d30691e94b18e152ec44ed90a23f55b266 (patch)
tree896015cada90b49858e1bf6503d9583704a56179 /res/res_agi.c
parent60cd1fa57deeb80b7a564fd81194797b503d4846 (diff)
add a library of timeval manipulation functions, and change a large number of usses to use the new functions (bug #4504)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6146 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_agi.c')
-rwxr-xr-xres/res_agi.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index dd1f161c7..f31591e3e 100755
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -787,7 +787,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
{
struct ast_filestream *fs;
struct ast_frame *f;
- struct timeval tv, start;
+ struct timeval start;
long sample_offset = 0;
int res = 0;
int ms;
@@ -854,7 +854,9 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
if (!res)
res = ast_waitstream(chan, argv[4]);
- if (!res) {
+ if (res) {
+ fdprintf(agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
+ } else {
fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0), 0, 0644);
if (!fs) {
res = -1;
@@ -870,9 +872,8 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
ast_seekstream(fs, sample_offset, SEEK_SET);
ast_truncstream(fs);
- gettimeofday(&start, NULL);
- gettimeofday(&tv, NULL);
- while ((ms < 0) || (((tv.tv_sec - start.tv_sec) * 1000 + (tv.tv_usec - start.tv_usec)/1000) < ms)) {
+ start = ast_tvnow();
+ while ((ms < 0) || ast_tvdiff_ms(ast_tvnow(), start) < ms) {
res = ast_waitfor(chan, -1);
if (res < 0) {
ast_closestream(fs);
@@ -926,7 +927,6 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
break;
}
ast_frfree(f);
- gettimeofday(&tv, NULL);
if (gotsilence)
break;
}
@@ -938,8 +938,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
}
fdprintf(agi->fd, "200 result=%d (timeout) endpos=%ld\n", res, sample_offset);
ast_closestream(fs);
- } else
- fdprintf(agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
+ }
if (silence > 0) {
res = ast_set_read_format(chan, rfmt);