[asterisk-commits] qwell: branch qwell/pimp_my_dtmf r385973 - /team/qwell/pimp_my_dtmf/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 17 11:32:26 CDT 2013
Author: qwell
Date: Wed Apr 17 11:32:23 2013
New Revision: 385973
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385973
Log:
Address review comments from Josh.
Modified:
team/qwell/pimp_my_dtmf/channels/chan_gulp.c
Modified: team/qwell/pimp_my_dtmf/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/pimp_my_dtmf/channels/chan_gulp.c?view=diff&rev=385973&r1=385972&r2=385973
==============================================================================
--- team/qwell/pimp_my_dtmf/channels/chan_gulp.c (original)
+++ team/qwell/pimp_my_dtmf/channels/chan_gulp.c Wed Apr 17 11:32:23 2013
@@ -825,14 +825,33 @@
}
struct info_dtmf_data {
+ struct ast_sip_session *session;
char digit;
unsigned int duration;
- struct ast_sip_session *session;
};
+static void info_dtmf_data_destroy(void *obj)
+{
+ struct info_dtmf_data *dtmf_data = obj;
+ ao2_ref(dtmf_data->session, -1);
+}
+
+static struct info_dtmf_data *info_dtmf_data_alloc(struct ast_sip_session *session, char digit, unsigned int duration)
+{
+ struct info_dtmf_data *dtmf_data = ao2_alloc(sizeof(*dtmf_data), info_dtmf_data_destroy);
+ if (!dtmf_data) {
+ return NULL;
+ }
+ ao2_ref(session, +1);
+ dtmf_data->session = session;
+ dtmf_data->digit = digit;
+ dtmf_data->duration = duration;
+ return dtmf_data;
+}
+
static int transmit_info_dtmf(void *data)
{
- struct info_dtmf_data *dtmf_data = data;
+ RAII_VAR(struct info_dtmf_data *, dtmf_data, data, ao2_cleanup);
struct ast_sip_session *session = dtmf_data->session;
struct pjsip_tx_data *tdata;
@@ -858,6 +877,7 @@
}
if (ast_sip_add_body(tdata, &body)) {
ast_log(LOG_ERROR, "Could not add body to DTMF INFO request\n");
+ pjsip_tx_data_dec_ref(tdata);
return -1;
}
ast_sip_session_send_request(session, tdata);
@@ -876,12 +896,13 @@
switch (session->endpoint->dtmf) {
case AST_SIP_DTMF_INFO:
{
- struct info_dtmf_data dtmf_data;
- dtmf_data.digit = digit;
- dtmf_data.duration = duration;
- dtmf_data.session = session;
-
- ast_sip_push_task(session->serializer, transmit_info_dtmf, &dtmf_data);
+ struct info_dtmf_data *dtmf_data = info_dtmf_data_alloc(session, digit, duration);
+
+ if (!dtmf_data) {
+ return -1;
+ }
+
+ ast_sip_push_task(session->serializer, transmit_info_dtmf, dtmf_data);
break;
}
case AST_SIP_DTMF_RFC_4733:
More information about the asterisk-commits
mailing list