<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9219">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">AMI PlayDTMF Action: Make not compete with channel's media thread.<br><br>There can be one and only one thread handling a channel's media at a time.<br>Otherwise, we don't know which thread is going to handle the media frames.<br><br>ASTERISK-27625<br><br>Change-Id: Ia341f1a6f4d54f2022261abec9021fe5b2eb4905<br>---<br>M apps/app_senddtmf.c<br>M include/asterisk/channel.h<br>M main/channel.c<br>3 files changed, 37 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/9219/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c<br>index 178b13f..e0362e7 100644<br>--- a/apps/app_senddtmf.c<br>+++ b/apps/app_senddtmf.c<br>@@ -167,7 +167,7 @@<br> return 0;<br> }<br> <br>- ast_senddigit(chan, *digit, duration_ms);<br>+ ast_senddigit_external(chan, *digit, duration_ms);<br> <br> chan = ast_channel_unref(chan);<br> <br>diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h<br>index c865a8a..91aed34 100644<br>--- a/include/asterisk/channel.h<br>+++ b/include/asterisk/channel.h<br>@@ -2177,14 +2177,32 @@<br> <br> /*!<br> * \brief Send a DTMF digit to a channel.<br>+ *<br> * \param chan channel to act upon<br> * \param digit the DTMF digit to send, encoded in ASCII<br> * \param duration the duration of the digit ending in ms<br>+ *<br>+ * \pre This must only be called by the channel's media handler thread.<br>+ *<br> * \return 0 on success, -1 on failure<br> */<br> int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);<br> <br> /*!<br>+ * \brief Send a DTMF digit to a channel from an external thread.<br>+ *<br>+ * \param chan channel to act upon<br>+ * \param digit the DTMF digit to send, encoded in ASCII<br>+ * \param duration the duration of the digit ending in ms<br>+ *<br>+ * \pre This must only be called by threads that are not the channel's<br>+ * media handler thread.<br>+ *<br>+ * \return 0 on success, -1 on failure<br>+ */<br>+int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);<br>+<br>+/*!<br> * \brief Send a DTMF digit to a channel.<br> * \param chan channel to act upon<br> * \param digit the DTMF digit to send, encoded in ASCII<br>diff --git a/main/channel.c b/main/channel.c<br>index d026121..6479597 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -4810,12 +4810,28 @@<br> <br> int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)<br> {<br>+ if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {<br>+ duration = AST_DEFAULT_EMULATE_DTMF_DURATION;<br>+ }<br> if (ast_channel_tech(chan)->send_digit_begin) {<br> ast_senddigit_begin(chan, digit);<br>- ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));<br>+ ast_safe_sleep(chan, duration);<br> }<br> <br>- return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));<br>+ return ast_senddigit_end(chan, digit, duration);<br>+}<br>+<br>+int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)<br>+{<br>+ if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {<br>+ duration = AST_DEFAULT_EMULATE_DTMF_DURATION;<br>+ }<br>+ if (ast_channel_tech(chan)->send_digit_begin) {<br>+ ast_senddigit_begin(chan, digit);<br>+ usleep(duration * 1000);<br>+ }<br>+<br>+ return ast_senddigit_end(chan, digit, duration);<br> }<br> <br> int ast_prod(struct ast_channel *chan)<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9219">change 9219</a>. To unsubscribe, 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/9219"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ia341f1a6f4d54f2022261abec9021fe5b2eb4905 </div>
<div style="display:none"> Gerrit-Change-Number: 9219 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>