mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
make Record() properly timeout even if no input is received from the channel (issue #4899)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6366 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -78,9 +78,8 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|||||||
int dspsilence = 0;
|
int dspsilence = 0;
|
||||||
int silence = 0; /* amount of silence to allow */
|
int silence = 0; /* amount of silence to allow */
|
||||||
int gotsilence = 0; /* did we timeout for silence? */
|
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? */
|
int gottimeout = 0; /* did we timeout for maxduration exceeded? */
|
||||||
time_t timeout = 0;
|
|
||||||
int option_skip = 0;
|
int option_skip = 0;
|
||||||
int option_noanswer = 0;
|
int option_noanswer = 0;
|
||||||
int option_append = 0;
|
int option_append = 0;
|
||||||
@@ -131,7 +130,8 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
if (maxstr) {
|
if (maxstr) {
|
||||||
if ((sscanf(maxstr, "%d", &i) == 1) && (i > -1))
|
if ((sscanf(maxstr, "%d", &i) == 1) && (i > -1))
|
||||||
maxduration = i;
|
/* Convert duration to milliseconds */
|
||||||
|
maxduration = i * 1000;
|
||||||
else if (!ast_strlen_zero(maxstr))
|
else if (!ast_strlen_zero(maxstr))
|
||||||
ast_log(LOG_WARNING, "'%s' is not a valid maximum duration\n", maxstr);
|
ast_log(LOG_WARNING, "'%s' is not a valid maximum duration\n", maxstr);
|
||||||
}
|
}
|
||||||
@@ -218,13 +218,18 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
if (maxduration > 0)
|
int waitres;
|
||||||
timeout = time(NULL) + (time_t)maxduration;
|
|
||||||
|
if (maxduration <= 0)
|
||||||
|
maxduration = -1;
|
||||||
|
|
||||||
while (ast_waitfor(chan, -1) > -1) {
|
while ((waitres = ast_waitfor(chan, maxduration)) > -1) {
|
||||||
if (maxduration > 0 && time(NULL) > timeout) {
|
if (maxduration > 0) {
|
||||||
gottimeout = 1;
|
if (waitres == 0) {
|
||||||
break;
|
gottimeout = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
maxduration = waitres;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = ast_read(chan);
|
f = ast_read(chan);
|
||||||
|
Reference in New Issue
Block a user