move codec destroy to destroy method like the other channels

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@716 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2009-04-14 19:03:03 +00:00
parent cc55c2b691
commit cafe6e82ad
1 changed files with 27 additions and 9 deletions

View File

@ -116,6 +116,7 @@ typedef struct private_object private_t;
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
@ -409,6 +410,24 @@ static switch_status_t channel_on_execute(switch_core_session_t *session)
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_destroy(switch_core_session_t *session)
{
private_t *tech_pvt = NULL;
if ((tech_pvt = switch_core_session_get_private(session))) {
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);
}
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
@ -462,14 +481,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
}
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
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);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
switch_mutex_lock(globals.mutex);
@ -868,7 +879,14 @@ switch_state_handler_table_t openzap_state_handlers = {
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
/*.on_soft_execute */ channel_on_soft_execute
/*.on_soft_execute */ channel_on_soft_execute,
/*.on_consume_media */ NULL,
/*.on_hibernate */ NULL,
/*.on_reset */ NULL,
/*.on_park*/ NULL,
/*.on_reporting*/ NULL,
/*.on_destroy*/ channel_on_destroy
};
switch_io_routines_t openzap_io_routines = {