From 545a34f25315a8144e80b861dcf43934b1ee8094 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 5 Feb 2008 15:50:49 +0000 Subject: [PATCH] pre-answer first! git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7522 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_ivr_async.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index ca0339ede2..f22720c1d6 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -970,7 +970,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_generate_session(switch_c switch_status_t status; switch_inband_dtmf_generate_t *pvt; - switch_assert(read_codec != NULL); + if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not install inband dtmf generate. Failed to pre_answer session!\n"); + return status; + } + + if (!read_codec) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not install inband dtmf generate. No read codec.!\n"); + return SWITCH_STATUS_FALSE; + } if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) { return SWITCH_STATUS_MEMERR; @@ -978,7 +986,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_generate_session(switch_c pvt->session = session; pvt->read = !!read_stream; - switch_channel_pre_answer(channel); if ((status = switch_core_media_bug_add(session, inband_dtmf_generate_callback, pvt, 0, pvt->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {