aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-15 23:00:47 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-15 23:00:47 +0000
commitff15e0fa53156b9994da3f726bfe91232de6195a (patch)
tree896015cada90b49858e1bf6503d9583704a56179 /res/res_agi.c
parentc05cf07847cb384ba66aa29d5eda580eda413ffb (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: http://svn.digium.com/svn/asterisk/trunk@6146 f38db490-d61c-443f-a65b-d21fe96a405b
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);