From a3ad1c2c0ac108f55ce50badfbdbde2d5e4ae23f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 20 Jan 2012 13:30:53 -0600 Subject: [PATCH] FS-3829 --resolve --- src/switch_core_codec.c | 12 +++++++++--- src/switch_core_io.c | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 6b78ed66f9..fd3c5e37f4 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -119,9 +119,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c } } else { /* replace real_read_codec */ switch_codec_t *cur_codec; - if (session->real_read_codec == session->read_codec) { - goto end; - } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec replaced with %s:%d\n", switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); /* Set real_read_codec to front of the list of read_codecs */ @@ -145,6 +142,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c } } } + + /* force media bugs to copy the read codec from the next frame */ + switch_thread_rwlock_wrlock(session->bug_rwlock); + if (switch_core_codec_ready(&session->bug_codec)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Destroying BUG Codec %s:%d\n", + session->bug_codec.implementation->iananame, session->bug_codec.implementation->ianacode); + switch_core_codec_destroy(&session->bug_codec); + } + switch_thread_rwlock_unlock(session->bug_rwlock); } else { status = SWITCH_STATUS_FALSE; goto end; diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 6be402824e..c55b891864 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -337,6 +337,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } if (!switch_core_codec_ready(&session->bug_codec)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting BUG Codec %s:%d\n", + read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode); switch_core_codec_copy(read_frame->codec, &session->bug_codec, NULL); } use_codec = &session->bug_codec;