[Asterisk-code-review] app_amd: Fixed timeout issue (asterisk[13])
Michael Cargile
asteriskteam at digium.com
Tue Nov 5 12:31:53 CST 2019
Michael Cargile has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13161 )
Change subject: app_amd: Fixed timeout issue
......................................................................
app_amd: Fixed timeout issue
ASTERISK-28143 attempted to fix an issue where calls with no audio would never
timeout. It did so by adding AST_FRAME_NULL as a frame type to process in its
calculations. Unfortunately these frames seem to show up at irregular time
intervals. This resulted in app_amd returning prematurely most of the time.
Removed AST_FRAME_NULL from the calculations and instead added an actual
timer that gets checked to see if the timeout has been reached.
Change-Id: I642a21b02d389b17e40ccd5357754b034c3daa42
---
M apps/app_amd.c
1 file changed, 18 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/61/13161/1
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 1c43591..9ebd516 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -277,6 +277,9 @@
/* Set silence threshold to specified value */
ast_dsp_set_threshold(silenceDetector, silenceThreshold);
+ /* Set our start time so we can tie the loop to real world time and not RTP updates */
+ struct timeval amd_tvstart = ast_tvnow();
+
/* Now we go into a loop waiting for frames from the channel */
while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {
int ms = 0;
@@ -295,7 +298,21 @@
break;
}
- if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_NULL || f->frametype == AST_FRAME_CNG) {
+ /* Check to make sure we haven't gone over our real-world timeout in case frames get stalled for whatever reason */
+ if ( (ast_tvdiff_ms(ast_tvnow(), amd_tvstart)) > totalAnalysisTime ) {
+ ast_frfree(f);
+ strcpy(amdStatus , "NOTSURE");
+ if ( audioFrameCount == 0 ) {
+ ast_verb(3, "AMD: Channel [%s]. No audio date recieved in [%d] seconds.\n", ast_channel_name(chan), totalAnalysisTime);
+ sprintf(amdCause , "NOAUDIODATA-%d", iTotalTime);
+ break;
+ }
+ ast_verb(3, "AMD: Channel [%s]. Timeout...\n", ast_channel_name(chan));
+ sprintf(amdCause , "TOOLONG-%d", iTotalTime);
+ break;
+ }
+
+ if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG) {
/* Figure out how long the frame is in milliseconds */
if (f->frametype == AST_FRAME_VOICE) {
framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13161
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I642a21b02d389b17e40ccd5357754b034c3daa42
Gerrit-Change-Number: 13161
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Cargile <mikec at vicidial.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191105/9a425b03/attachment.html>
More information about the asterisk-code-review
mailing list