2002-12-30 13:09:27 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2002-12-30 13:09:27 +00:00
|
|
|
*
|
2006-01-05 09:30:21 +00:00
|
|
|
* Copyright (C) 1999 - 2006, Digium, Inc.
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
|
|
|
* Mark Spencer <markster@digium.com>
|
2002-12-30 13:09:27 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2002-12-30 13:09:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Automatic channel service routines
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
|
|
|
* \author Mark Spencer <markster@digium.com>
|
2002-12-30 13:09:27 +00:00
|
|
|
*/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <signal.h>
|
2005-04-22 13:11:34 +00:00
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/frame.h"
|
|
|
|
#include "asterisk/sched.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
#include "asterisk/manager.h"
|
|
|
|
#include "asterisk/chanvars.h"
|
|
|
|
#include "asterisk/linkedlists.h"
|
|
|
|
#include "asterisk/indications.h"
|
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/utils.h"
|
2002-12-30 13:09:27 +00:00
|
|
|
|
|
|
|
#define MAX_AUTOMONS 256
|
|
|
|
|
|
|
|
struct asent {
|
|
|
|
struct ast_channel *chan;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
/*! This gets incremented each time autoservice gets started on the same
|
|
|
|
* channel. It will ensure that it doesn't actually get stopped until
|
|
|
|
* it gets stopped for the last time. */
|
|
|
|
unsigned int use_count;
|
|
|
|
AST_LIST_HEAD_NOLOCK(, ast_frame) dtmf_frames;
|
2006-01-03 08:54:19 +00:00
|
|
|
AST_LIST_ENTRY(asent) list;
|
2002-12-30 13:09:27 +00:00
|
|
|
};
|
|
|
|
|
2007-01-23 00:16:55 +00:00
|
|
|
static AST_RWLIST_HEAD_STATIC(aslist, asent);
|
2006-01-03 08:54:19 +00:00
|
|
|
|
2004-03-15 07:51:22 +00:00
|
|
|
static pthread_t asthread = AST_PTHREADT_NULL;
|
2002-12-30 13:09:27 +00:00
|
|
|
|
2007-12-07 16:11:00 +00:00
|
|
|
static void defer_frame(struct ast_channel *chan, struct ast_frame *f)
|
2002-12-30 13:09:27 +00:00
|
|
|
{
|
2007-12-07 16:11:00 +00:00
|
|
|
struct ast_frame *dup_f;
|
|
|
|
struct asent *as;
|
|
|
|
|
|
|
|
AST_RWLIST_WRLOCK(&aslist);
|
|
|
|
AST_RWLIST_TRAVERSE(&aslist, as, list) {
|
|
|
|
if (as->chan != chan)
|
|
|
|
continue;
|
|
|
|
if ((dup_f = ast_frdup(f)))
|
|
|
|
AST_LIST_INSERT_TAIL(&as->dtmf_frames, dup_f, frame_list);
|
|
|
|
}
|
|
|
|
AST_RWLIST_UNLOCK(&aslist);
|
|
|
|
}
|
2006-01-03 08:54:19 +00:00
|
|
|
|
2007-12-07 16:11:00 +00:00
|
|
|
static void *autoservice_run(void *ign)
|
|
|
|
{
|
2007-01-23 00:11:32 +00:00
|
|
|
for (;;) {
|
2007-06-12 14:16:37 +00:00
|
|
|
struct ast_channel *mons[MAX_AUTOMONS], *chan;
|
2006-02-15 01:38:20 +00:00
|
|
|
struct asent *as;
|
|
|
|
int x = 0, ms = 500;
|
|
|
|
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_RDLOCK(&aslist);
|
|
|
|
AST_RWLIST_TRAVERSE(&aslist, as, list) {
|
2007-08-01 15:39:54 +00:00
|
|
|
if (!ast_check_hangup(as->chan)) {
|
2002-12-30 13:09:27 +00:00
|
|
|
if (x < MAX_AUTOMONS)
|
|
|
|
mons[x++] = as->chan;
|
|
|
|
else
|
|
|
|
ast_log(LOG_WARNING, "Exceeded maximum number of automatic monitoring events. Fix autoservice.c\n");
|
|
|
|
}
|
|
|
|
}
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_UNLOCK(&aslist);
|
2002-12-30 13:09:27 +00:00
|
|
|
|
2007-06-12 14:16:37 +00:00
|
|
|
if ((chan = ast_waitfor_n(mons, x, &ms))) {
|
2006-02-15 01:38:20 +00:00
|
|
|
struct ast_frame *f = ast_read(chan);
|
2007-11-27 23:50:58 +00:00
|
|
|
|
2007-12-07 15:40:59 +00:00
|
|
|
if (!f) {
|
2007-12-07 16:11:00 +00:00
|
|
|
struct ast_frame hangup_frame = { 0, };
|
|
|
|
/* No frame means the channel has been hung up.
|
|
|
|
* A hangup frame needs to be queued here as ast_waitfor() may
|
|
|
|
* never return again for the condition to be detected outside
|
|
|
|
* of autoservice. So, we'll leave a HANGUP queued up so the
|
|
|
|
* thread in charge of this channel will know. */
|
|
|
|
|
|
|
|
hangup_frame.frametype = AST_FRAME_CONTROL;
|
|
|
|
hangup_frame.subclass = AST_CONTROL_HANGUP;
|
|
|
|
|
|
|
|
defer_frame(chan, &hangup_frame);
|
|
|
|
|
2007-11-27 23:50:58 +00:00
|
|
|
continue;
|
2007-12-07 15:40:59 +00:00
|
|
|
}
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
|
|
|
/* Do not add a default entry in this switch statement. Each new
|
|
|
|
* frame type should be addressed directly as to whether it should
|
|
|
|
* be queued up or not. */
|
|
|
|
switch (f->frametype) {
|
|
|
|
/* Save these frames */
|
|
|
|
case AST_FRAME_DTMF_BEGIN:
|
|
|
|
case AST_FRAME_DTMF_END:
|
|
|
|
case AST_FRAME_CONTROL:
|
|
|
|
case AST_FRAME_TEXT:
|
|
|
|
case AST_FRAME_IMAGE:
|
|
|
|
case AST_FRAME_HTML:
|
2007-12-07 16:11:00 +00:00
|
|
|
defer_frame(chan, f);
|
|
|
|
break;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
|
|
|
/* Throw these frames away */
|
|
|
|
case AST_FRAME_VOICE:
|
|
|
|
case AST_FRAME_VIDEO:
|
|
|
|
case AST_FRAME_NULL:
|
|
|
|
case AST_FRAME_IAX:
|
|
|
|
case AST_FRAME_CNG:
|
|
|
|
case AST_FRAME_MODEM:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
if (f)
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
|
|
|
}
|
2007-06-12 14:16:37 +00:00
|
|
|
|
2004-03-15 07:51:22 +00:00
|
|
|
asthread = AST_PTHREADT_NULL;
|
2007-06-12 14:16:37 +00:00
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_autoservice_start(struct ast_channel *chan)
|
|
|
|
{
|
2007-12-02 09:42:48 +00:00
|
|
|
int res = 0;
|
2002-12-30 13:09:27 +00:00
|
|
|
struct asent *as;
|
2007-01-23 00:16:55 +00:00
|
|
|
|
|
|
|
AST_RWLIST_WRLOCK(&aslist);
|
2006-01-03 08:54:19 +00:00
|
|
|
|
|
|
|
/* Check if the channel already has autoservice */
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_TRAVERSE(&aslist, as, list) {
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
if (as->chan == chan) {
|
|
|
|
as->use_count++;
|
2002-12-30 13:09:27 +00:00
|
|
|
break;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
}
|
2002-12-30 13:09:27 +00:00
|
|
|
}
|
2006-01-03 08:54:19 +00:00
|
|
|
|
|
|
|
/* If not, start autoservice on channel */
|
2007-12-02 09:42:48 +00:00
|
|
|
if (as) {
|
|
|
|
/* Entry extist, autoservice is already handling this channel */
|
|
|
|
} else if ((as = ast_calloc(1, sizeof(*as))) == NULL) {
|
|
|
|
/* Memory allocation failed */
|
|
|
|
res = -1;
|
|
|
|
} else {
|
|
|
|
/* New entry created */
|
2006-02-15 01:48:54 +00:00
|
|
|
as->chan = chan;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
as->use_count = 1;
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_INSERT_HEAD(&aslist, as, list);
|
2006-02-15 01:48:54 +00:00
|
|
|
if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
|
2006-10-04 19:51:38 +00:00
|
|
|
if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) {
|
2006-02-15 01:48:54 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
|
|
|
|
/* There will only be a single member in the list at this point,
|
|
|
|
the one we just added. */
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_REMOVE(&aslist, as, list);
|
2007-06-06 21:20:11 +00:00
|
|
|
ast_free(as);
|
2006-02-15 01:48:54 +00:00
|
|
|
res = -1;
|
|
|
|
} else
|
|
|
|
pthread_kill(asthread, SIGURG);
|
2002-12-30 13:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_UNLOCK(&aslist);
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_autoservice_stop(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
int res = -1;
|
2006-01-03 08:54:19 +00:00
|
|
|
struct asent *as;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
AST_LIST_HEAD_NOLOCK(, ast_frame) dtmf_frames;
|
|
|
|
struct ast_frame *f;
|
2007-12-02 09:42:48 +00:00
|
|
|
int removed = 0;
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
|
|
|
AST_LIST_HEAD_INIT_NOLOCK(&dtmf_frames);
|
2006-01-03 08:54:19 +00:00
|
|
|
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_WRLOCK(&aslist);
|
|
|
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) {
|
2006-01-03 08:54:19 +00:00
|
|
|
if (as->chan == chan) {
|
2007-11-08 05:28:47 +00:00
|
|
|
AST_RWLIST_REMOVE_CURRENT(list);
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
as->use_count--;
|
2007-12-02 09:42:48 +00:00
|
|
|
if (as->use_count)
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
break;
|
|
|
|
AST_LIST_APPEND_LIST(&dtmf_frames, &as->dtmf_frames, frame_list);
|
2007-06-06 21:20:11 +00:00
|
|
|
ast_free(as);
|
2007-12-02 09:42:48 +00:00
|
|
|
removed = 1;
|
2007-08-01 15:39:54 +00:00
|
|
|
if (!ast_check_hangup(chan))
|
2006-01-03 08:54:19 +00:00
|
|
|
res = 0;
|
2002-12-30 13:09:27 +00:00
|
|
|
break;
|
2006-01-03 08:54:19 +00:00
|
|
|
}
|
2002-12-30 13:09:27 +00:00
|
|
|
}
|
2007-11-08 05:28:47 +00:00
|
|
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
2006-01-03 08:54:19 +00:00
|
|
|
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
if (removed && asthread != AST_PTHREADT_NULL)
|
2002-12-30 13:09:27 +00:00
|
|
|
pthread_kill(asthread, SIGURG);
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
|
2007-01-23 00:16:55 +00:00
|
|
|
AST_RWLIST_UNLOCK(&aslist);
|
2006-01-03 08:54:19 +00:00
|
|
|
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
if (!removed)
|
|
|
|
return 0;
|
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
/* Wait for it to un-block */
|
2007-01-23 00:11:32 +00:00
|
|
|
while (ast_test_flag(chan, AST_FLAG_BLOCKING))
|
2002-12-30 13:09:27 +00:00
|
|
|
usleep(1000);
|
2007-06-12 14:16:37 +00:00
|
|
|
|
Merged revisions 89790 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r89790 | russell | 2007-11-27 15:45:51 -0600 (Tue, 27 Nov 2007) | 41 lines
Merge changes from team/russell/autoservice_1.4
This set of changes fixes an issue that was reported to me on IRC yesterday.
The user, d1mas, was using chan_zap for incoming calls and was having DTMF
recognition issues in some situations. Specifically, he noticed that the
problem occurred when using DISA or WaitExten. He also noticed that when
using Read, the problem did not occur. His system also used DUNDi for
dialplan lookups.
So, he theorized that if the DUNDi lookups blocked for some period of time,
that audio from the zap channel could get lost. If the audio got lost, then
it wouldn't be run through the DTMF detector, and digits could get lost.
He was correct, and the following set of changes fixes the problem. However,
the changes go a little bit further than what was necessary to fix this exact
problem.
1) I updated pbx_extension_helper() to autoservice the associated channel to
handle cases where extension lookups may take a long time. This would
normally be a dialplan switch that does some lookup over the network, such
as the DUNDi or IAX2 switches.
This ensures that even while a DUNDi lookup is blocking, the channel will be
continuously serviced.
2) I made a change to the autoservice code. This is actually something that
has bothered me for a long time. When a channel is in autoservice, _all_
frames get thrown away. However, some frames really shouldn't be thrown
away. The most notable examples are signalling (CONTROL) frames, and DTMF.
So, this patch queues up important frames while a channel is in autoservice.
When autoservice is stopped on the channel, the queued up frames get stuck
back on the channel so that they can get processed instead of thrown away.
3) I made another change to the autoservice code to handle the case where
autoservice is started on channels recursively.
Previously, you could call ast_autoservice_start() multiple times on a
channel, and it would stop the first time ast_autoservice_stop() gets
called. Now, it will ensure that autoservice doesn't actually stop until
the final call to ast_autoservice_stop().
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-27 22:05:36 +00:00
|
|
|
while ((f = AST_LIST_REMOVE_HEAD(&dtmf_frames, frame_list))) {
|
|
|
|
ast_queue_frame(chan, f);
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
|
|
|
|
2002-12-30 13:09:27 +00:00
|
|
|
return res;
|
|
|
|
}
|