aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_fax.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-16 21:10:15 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-16 21:10:15 +0000
commit0d442a7c2c619486abf5c5633fb423e6ea592d76 (patch)
treeb922d4113cce5ce50a4adcda3b8bcf400ab25b47 /apps/app_fax.c
parent78ca164fe19251dde45530f5fbe8fcf4d5ceed27 (diff)
Enable applications to enable/disable digit and tone detection.
Some applications (notably app_fax) do not need digit detection nor FAX tone detection while they are running, and if Asterisk is using software DSPs to provide the detection, this consumes extra CPU cycles that could be better spent on the actual application. This patch allows applications to query and control the state of digit and tone detection on a channel, and modifies app_fax to disable them while the FAX operations are occurring (and re-enable digit detection afterwards). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@201139 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r--apps/app_fax.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c
index bd6bdf9f6..e2b7a90ee 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -710,6 +710,7 @@ static int sndfax_exec(struct ast_channel *chan, const char *data)
int res = 0;
char *parse;
fax_session session;
+ char restore_digit_detect = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(file_name);
@@ -744,8 +745,32 @@ static int sndfax_exec(struct ast_channel *chan, const char *data)
session.chan = chan;
session.finished = 0;
+ /* get current digit detection mode, then disable digit detection if enabled */
+ {
+ int dummy = sizeof(restore_digit_detect);
+
+ ast_channel_queryoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, &dummy, 0);
+ }
+
+ if (restore_digit_detect) {
+ char new_digit_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &new_digit_detect, sizeof(new_digit_detect), 0);
+ }
+
+ /* disable FAX tone detection if enabled */
+ {
+ char new_fax_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_FAX_DETECT, &new_fax_detect, sizeof(new_fax_detect), 0);
+ }
+
res = transmit(&session);
+ if (restore_digit_detect) {
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, sizeof(restore_digit_detect), 0);
+ }
+
return res;
}
@@ -754,6 +779,7 @@ static int rcvfax_exec(struct ast_channel *chan, const char *data)
int res = 0;
char *parse;
fax_session session;
+ char restore_digit_detect = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(file_name);
@@ -788,8 +814,32 @@ static int rcvfax_exec(struct ast_channel *chan, const char *data)
session.chan = chan;
session.finished = 0;
+ /* get current digit detection mode, then disable digit detection if enabled */
+ {
+ int dummy = sizeof(restore_digit_detect);
+
+ ast_channel_queryoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, &dummy, 0);
+ }
+
+ if (restore_digit_detect) {
+ char new_digit_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &new_digit_detect, sizeof(new_digit_detect), 0);
+ }
+
+ /* disable FAX tone detection if enabled */
+ {
+ char new_fax_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_FAX_DETECT, &new_fax_detect, sizeof(new_fax_detect), 0);
+ }
+
res = transmit(&session);
+ if (restore_digit_detect) {
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, sizeof(restore_digit_detect), 0);
+ }
+
return res;
}