/**
 * \brief Destroys a Wanpipe Channel
 * \param ftdmchan Channel to destroy
 * \return Success
 */
static FIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
{
#ifdef LIBSANGOMA_VERSION
	if (ftdmchan->mod_data) {
		sangoma_wait_obj_t *sangoma_wait_obj;
		sangoma_wait_obj = ftdmchan->mod_data;
		ftdmchan->mod_data = NULL;
		sangoma_wait_obj_delete(&sangoma_wait_obj);
	}
#endif

	if (ftdmchan->sockfd != FTDM_INVALID_SOCKET) {
		/* enable HW DTMF. As odd as it seems. Why enable when the channel is being destroyed and won't be used anymore?
		 * because that way we can transfer the DTMF state back to the driver, if we're being restarted we will set again
		 * the FEATURE_DTMF flag and use HW DTMF, if we don't enable here, then on module restart we won't see
		 * HW DTMF available and will use software */
		if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_DTMF_DETECT)) {
			wanpipe_tdm_api_t tdm_api;
			int err;
			memset(&tdm_api, 0, sizeof(tdm_api));
			err = sangoma_tdm_enable_dtmf_events(ftdmchan->sockfd, &tdm_api);
			if (err) {
				ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed enabling Sangoma HW DTMF failed on channel destroy\n");
			}
		}
		sangoma_close(&ftdmchan->sockfd);
	}

	return FTDM_SUCCESS;
}
Exemple #2
0
/**
 * \brief Destroys a Wanpipe Channel
 * \param zchan Channel to destroy
 * \return Success
 */
static ZIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
{
#ifdef LIBSANGOMA_VERSION
    if (zchan->mod_data) {
        sangoma_wait_obj_t *sangoma_wait_obj;
        sangoma_wait_obj = zchan->mod_data;
        zchan->mod_data = NULL;
        sangoma_wait_obj_delete(&sangoma_wait_obj);
    }
#endif

    if (zchan->sockfd != ZAP_INVALID_SOCKET) {
        sangoma_close(&zchan->sockfd);
    }

    return ZAP_SUCCESS;
}