[Asterisk-code-review] AMI PlayDTMF Action: Make not compete with channel's media t... (asterisk[15])
Jenkins2
asteriskteam at digium.com
Thu Jun 21 09:09:49 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/9214 )
Change subject: AMI PlayDTMF Action: Make not compete with channel's media thread.
......................................................................
AMI PlayDTMF Action: Make not compete with channel's media thread.
There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.
ASTERISK-27625
Change-Id: Ia341f1a6f4d54f2022261abec9021fe5b2eb4905
---
M apps/app_senddtmf.c
M include/asterisk/channel.h
M main/channel.c
3 files changed, 37 insertions(+), 3 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Sean Bright: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index 178b13f..e0362e7 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -167,7 +167,7 @@
return 0;
}
- ast_senddigit(chan, *digit, duration_ms);
+ ast_senddigit_external(chan, *digit, duration_ms);
chan = ast_channel_unref(chan);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 295fcbe..16b8a7b 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -2225,14 +2225,32 @@
/*!
* \brief Send a DTMF digit to a channel.
+ *
* \param chan channel to act upon
* \param digit the DTMF digit to send, encoded in ASCII
* \param duration the duration of the digit ending in ms
+ *
+ * \pre This must only be called by the channel's media handler thread.
+ *
* \return 0 on success, -1 on failure
*/
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
/*!
+ * \brief Send a DTMF digit to a channel from an external thread.
+ *
+ * \param chan channel to act upon
+ * \param digit the DTMF digit to send, encoded in ASCII
+ * \param duration the duration of the digit ending in ms
+ *
+ * \pre This must only be called by threads that are not the channel's
+ * media handler thread.
+ *
+ * \return 0 on success, -1 on failure
+ */
+int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
+
+/*!
* \brief Send a DTMF digit to a channel.
* \param chan channel to act upon
* \param digit the DTMF digit to send, encoded in ASCII
diff --git a/main/channel.c b/main/channel.c
index 92ec444..a29c968 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4832,12 +4832,28 @@
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
{
+ if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
+ duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
+ }
if (ast_channel_tech(chan)->send_digit_begin) {
ast_senddigit_begin(chan, digit);
- ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
+ ast_safe_sleep(chan, duration);
}
- return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
+ return ast_senddigit_end(chan, digit, duration);
+}
+
+int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)
+{
+ if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
+ duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
+ }
+ if (ast_channel_tech(chan)->send_digit_begin) {
+ ast_senddigit_begin(chan, digit);
+ usleep(duration * 1000);
+ }
+
+ return ast_senddigit_end(chan, digit, duration);
}
int ast_prod(struct ast_channel *chan)
--
To view, visit https://gerrit.asterisk.org/9214
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia341f1a6f4d54f2022261abec9021fe5b2eb4905
Gerrit-Change-Number: 9214
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180621/b44c658a/attachment.html>
More information about the asterisk-code-review
mailing list