diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 0040ddc67d..09e4b1b8e8 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -797,7 +797,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switc \brief Reset the buffers and resampler on a session \param session the session to reset */ -SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session); +SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf); /*! \brief Write a frame to a session diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 56711cae75..f2b9cff6b2 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -4369,7 +4369,7 @@ SWITCH_STANDARD_APP(conference_function) switch_safe_free(dfile); } - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); /* release the readlock */ if (rl) { diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index d4fc57bdee..71cb0495b2 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -624,7 +624,7 @@ SWITCH_STANDARD_APP(rss_function) } switch_xml_free(xml); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); } diff --git a/src/mod/codecs/mod_amr/mod_amr.c b/src/mod/codecs/mod_amr/mod_amr.c index ac493b4cdd..56550071c2 100644 --- a/src/mod/codecs/mod_amr/mod_amr.c +++ b/src/mod/codecs/mod_amr/mod_amr.c @@ -37,8 +37,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load); SWITCH_MODULE_DEFINITION(mod_amr, mod_amr_load, NULL, NULL); #ifndef AMR_PASSTHROUGH -#include "amr/interf_enc.h" -#include "amr/interf_dec.h" +#include "interf_enc.h" +#include "interf_dec.h" /* * Check section 8.1 of rfc3267 for possible sdp options. diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index b29219280b..04f9e65e99 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1016,7 +1016,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force) tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding); switch_core_codec_destroy(&tech_pvt->read_codec); switch_core_codec_destroy(&tech_pvt->write_codec); - switch_core_session_reset(tech_pvt->session); + switch_core_session_reset(tech_pvt->session, SWITCH_TRUE); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->read_codec.implementation->iananame); return SWITCH_STATUS_SUCCESS; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 1a9b492fb8..ff95870594 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -575,11 +575,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch } -SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session) +SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf) { switch_channel_t *channel; switch_size_t has; + channel = switch_core_session_get_channel(session); + switch_assert(channel != NULL); + /* clear resamplers*/ switch_resample_destroy(&session->read_resampler); switch_resample_destroy(&session->write_resampler); @@ -590,12 +593,11 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session) /* wipe theese, they will be recreated if need be */ switch_buffer_destroy(&session->raw_read_buffer); switch_buffer_destroy(&session->raw_write_buffer); - - /* flush dtmf */ - channel = switch_core_session_get_channel(session); - - while ((has = switch_channel_has_dtmf(channel))) { - switch_channel_flush_dtmf(channel); + + if (flush_dtmf) { + while ((has = switch_channel_has_dtmf(channel))) { + switch_channel_flush_dtmf(channel); + } } switch_ivr_deactivate_unicast(session); diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 207e84fb22..36fed03536 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -220,7 +220,7 @@ static void switch_core_standard_on_park(switch_core_session_t *session) switch_assert(session != NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard PARK\n"); switch_channel_clear_flag(session->channel, CF_TRANSFER); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); switch_ivr_park(session, NULL); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index e3584ce9d6..1155d8c7d6 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -882,7 +882,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ const char *uuid = NULL; switch_assert(session != NULL); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); channel = switch_core_session_get_channel(session); switch_assert(channel != NULL); diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index a7c4472031..8cf448e08e 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -300,7 +300,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_ SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return SWITCH_STATUS_GENERR; } @@ -664,7 +664,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session status = SWITCH_STATUS_SUCCESS; switch_core_session_set_read_codec(session, read_codec); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); } return status; @@ -720,7 +720,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", file); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return SWITCH_STATUS_GENERR; } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 495ee2a259..88abe4be24 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -222,7 +222,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) end: switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK); - switch_core_session_reset(session_a); + switch_core_session_reset(session_a, SWITCH_TRUE); switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a)); switch_channel_clear_flag(chan_a, CF_BRIDGED); @@ -353,8 +353,8 @@ static switch_status_t uuid_bridge_on_transmit(switch_core_session_t *session) switch_channel_clear_flag(channel, CF_TRANSFER); switch_channel_clear_flag(other_channel, CF_TRANSFER); - switch_core_session_reset(session); - switch_core_session_reset(other_session); + switch_core_session_reset(session, SWITCH_TRUE); + switch_core_session_reset(other_session, SWITCH_TRUE); ready_a = switch_channel_ready(channel); ready_b = switch_channel_ready(other_channel); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 402e560f8b..3e735fb673 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -448,7 +448,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t if (!pass && write_codec.implementation) { if (read_codec && !ringback.asis) { switch_core_session_set_read_codec(session, read_codec); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); } switch_core_codec_destroy(&write_codec); } @@ -1116,7 +1116,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) { - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_FALSE); } for (i = 0; i < and_argc; i++) { @@ -1243,7 +1243,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (!pass && write_codec.implementation) { if (read_codec && !ringback.asis) { switch_core_session_set_read_codec(session, read_codec); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_FALSE); } switch_core_codec_destroy(&write_codec); } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 9bea1f61d3..ae5a2ff237 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -371,7 +371,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se read_codec->implementation->actual_samples_per_second, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return SWITCH_STATUS_GENERR; } @@ -429,7 +429,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, read_codec->implementation->microseconds_per_frame / 1000); switch_core_file_close(fh); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return SWITCH_STATUS_GENERR; } @@ -551,7 +551,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se switch_core_session_set_read_codec(session, read_codec); switch_core_file_close(fh); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return status; } @@ -747,7 +747,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess read_codec->implementation->number_of_channels, read_codec->implementation->actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); status = SWITCH_STATUS_NOTFOUND; goto end; } @@ -812,7 +812,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup buffer failed\n"); switch_core_file_close(fh); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); status = SWITCH_STATUS_GENERR; goto end; @@ -839,7 +839,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval); switch_core_file_close(fh); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); status = SWITCH_STATUS_GENERR; goto end; } @@ -856,7 +856,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); switch_core_codec_destroy(&codec); switch_core_file_close(fh); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); status = SWITCH_STATUS_GENERR; goto end; } @@ -1103,7 +1103,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess end: free(abuf); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return status; } @@ -1566,7 +1566,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses timer_name = switch_channel_get_variable(channel, "timer_name"); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); read_codec = switch_core_session_get_read_codec(session); rate = read_codec->implementation->actual_samples_per_second; @@ -1577,7 +1577,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses if (switch_core_speech_open(sh, tts_name, voice_name, (uint32_t) rate, interval, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n"); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); if (cache_obj) { switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL); } @@ -1603,7 +1603,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name, rate, interval); flags = 0; switch_core_speech_close(sh, &flags); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); if (cache_obj) { switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL); } @@ -1620,7 +1620,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses switch_core_codec_destroy(write_frame.codec); flags = 0; switch_core_speech_close(sh, &flags); - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); if (cache_obj) { switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL); } @@ -1650,6 +1650,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses } } - switch_core_session_reset(session); + switch_core_session_reset(session, SWITCH_TRUE); return status; }