summaryrefslogtreecommitdiff
path: root/apps/app_record.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-09-15 01:17:51 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-09-15 01:17:51 +0000
commit44e3b6feb146b4f84215ac19a008967ef867444f (patch)
treed732e7797079d2c9f1687a1a8fd24b50e82ef49f /apps/app_record.c
parent5bd40f4e11457985d268cd7e19bed0c9368a35c3 (diff)
ensure that Record() will exit even if no audio is received from the channel (issue #4899)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6610 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_record.c')
-rwxr-xr-xapps/app_record.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/app_record.c b/apps/app_record.c
index 6c27dc1ee..bed5bd398 100755
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -89,9 +89,8 @@ static int record_exec(struct ast_channel *chan, void *data)
int dspsilence = 0;
int silence = 0; /* amount of silence to allow */
int gotsilence = 0; /* did we timeout for silence? */
- int maxduration = 0; /* max duration of recording */
+ int maxduration = 0; /* max duration of recording in milliseconds */
int gottimeout = 0; /* did we timeout for maxduration exceeded? */
- time_t timeout = 0;
int option_skip = 0;
int option_noanswer = 0;
int option_append = 0;
@@ -142,7 +141,8 @@ static int record_exec(struct ast_channel *chan, void *data)
if (maxstr) {
if ((sscanf(maxstr, "%d", &i) == 1) && (i > -1))
- maxduration = i;
+ /* Convert duration to milliseconds */
+ maxduration = i * 1000;
else if (!ast_strlen_zero(maxstr))
ast_log(LOG_WARNING, "'%s' is not a valid maximum duration\n", maxstr);
}
@@ -227,19 +227,23 @@ static int record_exec(struct ast_channel *chan, void *data)
flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
s = ast_writefile( tmp, ext, NULL, flags , 0, 0644);
-
if (s) {
+ int waitres;
+
/* Request a video update */
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
- if (maxduration > 0)
- timeout = time(NULL) + (time_t)maxduration;
+ if (maxduration <= 0)
+ maxduration = -1;
- while (ast_waitfor(chan, -1) > -1) {
- if (maxduration > 0 && time(NULL) > timeout) {
- gottimeout = 1;
- break;
- }
+ while ((waitres = ast_waitfor(chan, maxduration)) > -1) {
+ if (maxduration > 0) {
+ if (waitres == 0) {
+ gottimeout = 1;
+ break;
+ }
+ maxduration = waitres;
+ }
f = ast_read(chan);
if (!f) {