<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17712">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">say.c: Honor requests for DTMF interruption.<br><br>SayAlpha, SayAlphaCase, SayDigits, SayMoney, SayNumber, SayOrdinal,<br>and SayPhonetic all claim to allow DTMF interruption if the<br>SAY_DTMF_INTERRUPT channel variable is set to a truthy value, but we<br>are failing to break out of a given 'say' application if DTMF actually<br>occurs.<br><br>ASTERISK-29816 #close<br><br>Change-Id: I6a96e0130560831d2cb45164919862b9bcb6287e<br>---<br>M main/pbx_builtins.c<br>M main/say.c<br>2 files changed, 34 insertions(+), 67 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/17712/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/pbx_builtins.c b/main/pbx_builtins.c</span><br><span>index eae4c6b..93b0af0 100644</span><br><span>--- a/main/pbx_builtins.c</span><br><span>+++ b/main/pbx_builtins.c</span><br><span>@@ -1323,6 +1323,25 @@</span><br><span> return pbx_builtin_goto(chan, branch);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Determine if DTMF interruption was requested.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * If the SAY_DTMF_INTERRUPT channel variable is truthy, the caller has</span><br><span style="color: hsl(120, 100%, 40%);">+ * requested DTMF interruption be enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param chan the channel to examine.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int permit_dtmf_interrupt(struct ast_channel *chan)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int interrupt;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_lock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ interrupt = ast_true(pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT"));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return interrupt;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int pbx_builtin_saynumber(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> char tmp[256];</span><br><span>@@ -1330,15 +1349,7 @@</span><br><span> int number_val;</span><br><span> char *options;</span><br><span> int res;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ int interrupt = permit_dtmf_interrupt(chan);</span><br><span> </span><br><span> if (ast_strlen_zero(data)) {</span><br><span> ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");</span><br><span>@@ -1377,15 +1388,7 @@</span><br><span> int number_val;</span><br><span> char *options;</span><br><span> int res;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ int interrupt = permit_dtmf_interrupt(chan);</span><br><span> </span><br><span> if (ast_strlen_zero(data)) {</span><br><span> ast_log(LOG_WARNING, "SayOrdinal requires an argument (number)\n");</span><br><span>@@ -1420,18 +1423,9 @@</span><br><span> static int pbx_builtin_saydigits(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> int res = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span> </span><br><span> if (data) {</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_say_digit_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_say_digit_str(chan, data, permit_dtmf_interrupt(chan) ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span> }</span><br><span> </span><br><span> return res;</span><br><span>@@ -1440,18 +1434,9 @@</span><br><span> static int pbx_builtin_saymoney(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> int res = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span> </span><br><span> if (data) {</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_say_money_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_say_money_str(chan, data, permit_dtmf_interrupt(chan) ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span> }</span><br><span> </span><br><span> return res;</span><br><span>@@ -1462,21 +1447,12 @@</span><br><span> int res = 0;</span><br><span> int sensitivity = 0;</span><br><span> char *parse;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span> </span><br><span> AST_DECLARE_APP_ARGS(args,</span><br><span> AST_APP_ARG(options);</span><br><span> AST_APP_ARG(characters);</span><br><span> );</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> if (ast_strlen_zero(data)) {</span><br><span> ast_log(LOG_WARNING, "SayAlphaCase requires two arguments (options, characters)\n");</span><br><span> return 0;</span><br><span>@@ -1508,7 +1484,7 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_say_character_str(chan, args.characters, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), sensitivity);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_say_character_str(chan, args.characters, permit_dtmf_interrupt(chan) ? AST_DIGIT_ANY : "", ast_channel_language(chan), sensitivity);</span><br><span> </span><br><span> return res;</span><br><span> }</span><br><span>@@ -1516,18 +1492,9 @@</span><br><span> static int pbx_builtin_saycharacters(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> int res = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span> </span><br><span> if (data) {</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_say_character_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan), AST_SAY_CASE_NONE);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_say_character_str(chan, data, permit_dtmf_interrupt(chan) ? AST_DIGIT_ANY : "", ast_channel_language(chan), AST_SAY_CASE_NONE);</span><br><span> }</span><br><span> </span><br><span> return res;</span><br><span>@@ -1536,18 +1503,11 @@</span><br><span> static int pbx_builtin_sayphonetic(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> int res = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- int interrupt = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *interrupt_string;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_lock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_true(interrupt_string)) {</span><br><span style="color: hsl(0, 100%, 40%);">- interrupt = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (data) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_say_phonetic_str(chan, data, permit_dtmf_interrupt(chan) ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_unlock(chan);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (data)</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_say_phonetic_str(chan, data, interrupt ? AST_DIGIT_ANY : "", ast_channel_language(chan));</span><br><span> return res;</span><br><span> }</span><br><span> </span><br><span>diff --git a/main/say.c b/main/say.c</span><br><span>index bb0c0a6..54aefe0 100644</span><br><span>--- a/main/say.c</span><br><span>+++ b/main/say.c</span><br><span>@@ -189,6 +189,13 @@</span><br><span> res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);</span><br><span> else</span><br><span> res = ast_waitstream(chan, ints);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* We were interrupted by a digit */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stopstream(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(filenames);</span><br><span style="color: hsl(120, 100%, 40%);">+ return res;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> ast_stopstream(chan);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17712">change 17712</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17712"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I6a96e0130560831d2cb45164919862b9bcb6287e </div>
<div style="display:none"> Gerrit-Change-Number: 17712 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>