From 73fe7bfdcca8e60fba2a60273a43deb04b70a65b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 10 Apr 2009 20:14:02 +0000 Subject: [PATCH] FSCORE-352 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12987 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_alsa/mod_alsa.c | 10 ++-- .../endpoints/mod_dingaling/mod_dingaling.c | 28 +++++----- src/mod/endpoints/mod_iax/mod_iax.c | 16 +++--- src/mod/endpoints/mod_loopback/mod_loopback.c | 19 +++---- src/mod/endpoints/mod_opal/mod_opal.cpp | 52 +++++++++---------- .../endpoints/mod_reference/mod_reference.c | 16 +++--- src/mod/endpoints/mod_skypiax/mod_skypiax.c | 23 ++++---- src/mod/endpoints/mod_sofia/mod_sofia.c | 32 ++++++------ src/mod/endpoints/mod_unicall/mod_unicall.c | 20 +++---- 9 files changed, 109 insertions(+), 107 deletions(-) diff --git a/src/mod/endpoints/mod_alsa/mod_alsa.c b/src/mod/endpoints/mod_alsa/mod_alsa.c index 7e215f3426..4fc3008bd1 100644 --- a/src/mod/endpoints/mod_alsa/mod_alsa.c +++ b/src/mod/endpoints/mod_alsa/mod_alsa.c @@ -428,14 +428,12 @@ static void remove_pvt(private_t *tech_pvt) static switch_status_t channel_on_destroy(switch_core_session_t *session) { - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; + //switch_channel_t *channel = NULL; + //private_t *tech_pvt = NULL; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + //channel = switch_core_session_get_channel(session); + //tech_pvt = switch_core_session_get_private(session); - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 998a829a9d..ef14b8d74e 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1214,23 +1214,23 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) struct private_object *tech_pvt = NULL; tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - if (tech_pvt->rtp_session) { - switch_rtp_destroy(&tech_pvt->rtp_session); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NUKE RTP\n"); - tech_pvt->rtp_session = NULL; + if (tech_pvt) { + if (tech_pvt->rtp_session) { + switch_rtp_destroy(&tech_pvt->rtp_session); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NUKE RTP\n"); + tech_pvt->rtp_session = NULL; + } + + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } } - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index 78368e12a4..eeb4370958 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -493,14 +493,14 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) { private_t *tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (!switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); + if (tech_pvt) { + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (!switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } } return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index ebb890aabd..a943a5460c 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -353,16 +353,17 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) switch_assert(channel != NULL); tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - switch_core_timer_destroy(&tech_pvt->timer); - - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); + if (tech_pvt) { + switch_core_timer_destroy(&tech_pvt->timer); + + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } } diff --git a/src/mod/endpoints/mod_opal/mod_opal.cpp b/src/mod/endpoints/mod_opal/mod_opal.cpp index 38c93ab929..ac3a9fd74b 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.cpp +++ b/src/mod/endpoints/mod_opal/mod_opal.cpp @@ -835,38 +835,36 @@ switch_status_t FSConnection::on_execute() static switch_status_t on_destroy(switch_core_session_t *session) { - switch_channel_t *channel = switch_core_session_get_channel(session); + //switch_channel_t *channel = switch_core_session_get_channel(session); opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); - if (tech_pvt->read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->read_codec); + if (tech_pvt) { + if (tech_pvt->read_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + + if (tech_pvt->vid_read_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->vid_read_codec); + } + + if (tech_pvt->vid_write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->vid_write_codec); + } + + if (tech_pvt->read_timer.timer_interface) { + switch_core_timer_destroy(&tech_pvt->read_timer); + } + + if (tech_pvt->vid_read_timer.timer_interface) { + switch_core_timer_destroy(&tech_pvt->vid_read_timer); + } } - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - if (tech_pvt->vid_read_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->vid_read_codec); - } - - if (tech_pvt->vid_write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->vid_write_codec); - } - - if (tech_pvt->read_timer.timer_interface) { - switch_core_timer_destroy(&tech_pvt->read_timer); - } - - if (tech_pvt->vid_read_timer.timer_interface) { - switch_core_timer_destroy(&tech_pvt->vid_read_timer); - } - - switch_core_session_unset_read_codec(session); - switch_core_session_unset_write_codec(session); - return SWITCH_STATUS_SUCCESS; - } /* this function has to be called with the original session beause the FSConnection might already be destroyed and we diff --git a/src/mod/endpoints/mod_reference/mod_reference.c b/src/mod/endpoints/mod_reference/mod_reference.c index c6bcb17556..b7011eb61c 100644 --- a/src/mod/endpoints/mod_reference/mod_reference.c +++ b/src/mod/endpoints/mod_reference/mod_reference.c @@ -195,15 +195,15 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) assert(channel != NULL); tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); + if (tech_pvt) { + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } } return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_skypiax/mod_skypiax.c b/src/mod/endpoints/mod_skypiax/mod_skypiax.c index 33f10e88b2..67624e9187 100644 --- a/src/mod/endpoints/mod_skypiax/mod_skypiax.c +++ b/src/mod/endpoints/mod_skypiax/mod_skypiax.c @@ -183,23 +183,24 @@ static switch_status_t channel_on_init(switch_core_session_t * session) return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_hangup(switch_core_session_t * session) +static switch_status_t channel_on_destroy(switch_core_session_t * session) { - switch_channel_t *channel = NULL; + //switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); + //channel = switch_core_session_get_channel(session); + //switch_assert(channel != NULL); tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); + if (tech_pvt) { + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } } return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 2053e1f6ad..4e51a241c6 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -239,23 +239,25 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA DESTROY\n", switch_channel_get_name(channel)); - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); + if (tech_pvt) { + if (switch_core_codec_ready(&tech_pvt->read_codec)) { + switch_core_codec_destroy(&tech_pvt->read_codec); + } + + if (switch_core_codec_ready(&tech_pvt->write_codec)) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + + switch_core_session_unset_read_codec(session); + switch_core_session_unset_write_codec(session); + + switch_mutex_lock(tech_pvt->profile->flag_mutex); + tech_pvt->profile->inuse--; + switch_mutex_unlock(tech_pvt->profile->flag_mutex); + + sofia_glue_deactivate_rtp(tech_pvt); } - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - switch_core_session_unset_read_codec(session); - switch_core_session_unset_write_codec(session); - - switch_mutex_lock(tech_pvt->profile->flag_mutex); - tech_pvt->profile->inuse--; - switch_mutex_unlock(tech_pvt->profile->flag_mutex); - - sofia_glue_deactivate_rtp(tech_pvt); - return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_unicall/mod_unicall.c b/src/mod/endpoints/mod_unicall/mod_unicall.c index da9907dc5a..4d9491be3a 100644 --- a/src/mod/endpoints/mod_unicall/mod_unicall.c +++ b/src/mod/endpoints/mod_unicall/mod_unicall.c @@ -934,18 +934,20 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_execute(%p)\n static switch_status_t unicall_on_destroy(switch_core_session_t *session) { - switch_channel_t *channel; + //switch_channel_t *channel; private_t *tech_pvt; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + //channel = switch_core_session_get_channel(session); + //assert(channel != NULL); - if (switch_core_codec_ready(&tech_pvt->read_codec)) - switch_core_codec_destroy(&tech_pvt->read_codec); - if (switch_core_codec_ready(&tech_pvt->write_codec)) - switch_core_codec_destroy(&tech_pvt->write_codec); + tech_pvt = switch_core_session_get_private(session); + + if (tech_pvt) { + if (switch_core_codec_ready(&tech_pvt->read_codec)) + switch_core_codec_destroy(&tech_pvt->read_codec); + if (switch_core_codec_ready(&tech_pvt->write_codec)) + switch_core_codec_destroy(&tech_pvt->write_codec); + } return SWITCH_STATUS_SUCCESS;