aboutsummaryrefslogtreecommitdiffstats
path: root/main/channel.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-02 22:59:09 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-02 22:59:09 +0000
commit97d4c0ac592fc6d98992525800ced123e5b2d0a5 (patch)
tree941d59fcd313b7c365f9c6f20c4fad83a34cef70 /main/channel.c
parent9c27f7b3dd797724623159b19c1d64d07482b47d (diff)
Merge changes from team/russell/inband_dtmf ...
Fix some issues related to generating inband DTMF. There are two changes here: 1) The list of DTMF tones in the senddigit_begin() function explicitly specified 100ms of the tone followed by 100ms of silence. This really broke things with the way that Asterisk now wants complete control over when the digit begins and ends. So, regardless of what Asterisk really wanted to do, this was going to play out the tone at the length it wanted to. This caused various problems like DTMF translation to inband to be extremely unreliable. The list of tones has been changed so that the correct DTMF tone is played indefinitely until Asterisk tells it to stop. 2) ast_write() had to be modified to let a DTMF_END frame get processed even when a generator is present. This is how the tone will finally get stopped. (issues #8944, #9250, #9348, maybe others. Thanks to mdu113 from #8944 for the testing and feedback!) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@62789 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/main/channel.c b/main/channel.c
index 44dfd2ded..cd568da0e 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2583,27 +2583,27 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
res = chan->tech->send_digit_begin(chan, digit);
if (res) {
- /*
- * Device does not support DTMF tones, lets fake
- * it by doing our own generation. (PM2002)
- */
+ /* Device does not support DTMF tones, lets fake
+ * it by doing our own generation. */
static const char* dtmf_tones[] = {
- "!941+1336/100,!0/100", /* 0 */
- "!697+1209/100,!0/100", /* 1 */
- "!697+1336/100,!0/100", /* 2 */
- "!697+1477/100,!0/100", /* 3 */
- "!770+1209/100,!0/100", /* 4 */
- "!770+1336/100,!0/100", /* 5 */
- "!770+1477/100,!0/100", /* 6 */
- "!852+1209/100,!0/100", /* 7 */
- "!852+1336/100,!0/100", /* 8 */
- "!852+1477/100,!0/100", /* 9 */
- "!697+1633/100,!0/100", /* A */
- "!770+1633/100,!0/100", /* B */
- "!852+1633/100,!0/100", /* C */
- "!941+1633/100,!0/100", /* D */
- "!941+1209/100,!0/100", /* * */
- "!941+1477/100,!0/100" }; /* # */
+ "941+1336", /* 0 */
+ "697+1209", /* 1 */
+ "697+1336", /* 2 */
+ "697+1477", /* 3 */
+ "770+1209", /* 4 */
+ "770+1336", /* 5 */
+ "770+1477", /* 6 */
+ "852+1209", /* 7 */
+ "852+1336", /* 8 */
+ "852+1477", /* 9 */
+ "697+1633", /* A */
+ "770+1633", /* B */
+ "852+1633", /* C */
+ "941+1633", /* D */
+ "941+1209", /* * */
+ "941+1477" /* # */
+ };
+
if (digit >= '0' && digit <='9')
ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
else if (digit >= 'A' && digit <= 'D')
@@ -2697,6 +2697,17 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
if (ast_test_flag(chan, AST_FLAG_WRITE_INT))
ast_deactivate_generator(chan);
else {
+ if (fr->frametype == AST_FRAME_DTMF_END) {
+ /* There is a generator running while we're in the middle of a digit.
+ * It's probably inband DTMF, so go ahead and pass it so it can
+ * stop the generator */
+ ast_clear_flag(chan, AST_FLAG_BLOCKING);
+ ast_channel_unlock(chan);
+ res = ast_senddigit_end(chan, fr->subclass, fr->len);
+ ast_channel_lock(chan);
+ CHECK_BLOCKING(chan);
+ }
+
res = 0; /* XXX explain, why 0 ? */
goto done;
}