diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 8e6f717602a..c4f417e4eed 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -48,7 +48,10 @@ SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t switch_mutex_t *mutex = NULL; switch_mutex_lock(session->codec_read_mutex); - if (session->read_codec) mutex = session->read_codec->mutex; + if (session->read_codec) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Read codec addr: %p is set to NULL\n", (void *)&session->read_codec); + mutex = session->read_codec->mutex; + } if (mutex) switch_mutex_lock(mutex); session->real_read_codec = session->read_codec = NULL; session->raw_read_frame.codec = session->read_codec; @@ -112,6 +115,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec set to %s:%d\n", switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); session->read_codec = session->real_read_codec = codec; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Read codec addr: %p\n", (void *)&session->read_codec); changed_read_codec = 1; if (codec->implementation) { session->read_impl = *codec->implementation; @@ -724,6 +728,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec implementation->init(codec, flags, codec_settings); switch_mutex_init(&codec->mutex, SWITCH_MUTEX_NESTED, codec->memory_pool); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec mutex addr: %p\n", (void *)&codec->mutex); + switch_set_flag(codec, SWITCH_CODEC_FLAG_READY); return SWITCH_STATUS_SUCCESS; } else { @@ -941,6 +947,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec) if (mutex) switch_mutex_unlock(mutex); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec read mutex addr: %p has been set to NULL\n", (void *)&mutex); + if (free_pool) { switch_core_destroy_memory_pool(&pool); } diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 397878eec6e..e6fd688a40d 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -81,6 +81,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_os_yield(); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Codec read mutex addr: %p\n", (void *)&session->codec_read_mutex); + if (switch_mutex_trylock(session->codec_read_mutex) == SWITCH_STATUS_SUCCESS) { switch_mutex_unlock(session->codec_read_mutex); } else { @@ -186,8 +188,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_mutex_unlock(session->read_codec->mutex); switch_mutex_unlock(session->codec_read_mutex); if ((status = session->endpoint_interface->io_routines->read_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Codec read mutex addr: %p\n", (void *)&session->codec_read_mutex); for (ptr = session->event_hooks.read_frame; ptr; ptr = ptr->next) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Codec read mutex addr: %p\n", (void *)&session->codec_read_mutex); if ((status = ptr->read_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Codec read mutex addr: %p\n", (void *)&session->codec_read_mutex); break; } } @@ -988,6 +993,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi even_more_done: + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Read codec addr: %p, codec read mutex addr: %p\n", (void *)&session->read_codec, (void *)&session->codec_read_mutex); + if (!*frame || (!switch_test_flag(*frame, SFF_PROXY_PACKET) && (!(*frame)->codec || !(*frame)->codec->implementation || !switch_core_codec_ready((*frame)->codec)))) { diff --git a/src/switch_core_session.c b/src/switch_core_session.c index c0391cbda86..118060b68a0 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -2689,6 +2689,8 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_ switch_channel_set_variable_printf(session->channel, "session_id", "%u", session->id); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Codec read mutex addr: %p\n", (void *)&session->codec_read_mutex); + return session; }