From b513d1ff02e18da347e95bceab54c135d010d2cf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 6 Sep 2013 00:05:00 +0500 Subject: [PATCH] fix possible issue with double read of frames in conf --- src/mod/applications/mod_conference/mod_conference.c | 7 +++++-- src/switch_core_io.c | 6 ++++++ src/switch_core_media.c | 7 +------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 0ad4c1bc67..6007fb2047 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1459,6 +1459,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe if (switch_channel_test_flag(channel, CF_VIDEO)) { if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) { switch_channel_set_flag(channel, CF_VIDEO_ECHO); + switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE); } else { switch_channel_clear_flag(channel, CF_VIDEO_ECHO); } @@ -1618,7 +1619,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf if (member) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Adding video floor %s\n", switch_channel_get_name(member->channel)); - switch_channel_set_flag(member->channel, CF_VIDEO_PASSIVE); + //switch_channel_set_flag(member->channel, CF_VIDEO_PASSIVE); switch_core_session_refresh_video(member->session); conference->video_floor_holder = member; } else { @@ -1627,7 +1628,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf if (old_member) { old_id = old_member->id; - switch_channel_clear_flag(old_member->channel, CF_VIDEO_PASSIVE); + //switch_channel_clear_flag(old_member->channel, CF_VIDEO_PASSIVE); } switch_set_flag(conference, CFLAG_FLOOR_CHANGE); @@ -7488,6 +7489,7 @@ SWITCH_STANDARD_APP(conference_function) switch_core_session_video_reset(session); switch_channel_set_flag(channel, CF_CONFERENCE); + switch_channel_set_flag(channel, CF_VIDEO_PASSIVE); if (switch_channel_answer(channel) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Channel answer failed.\n"); @@ -8042,6 +8044,7 @@ SWITCH_STANDARD_APP(conference_function) end: switch_channel_clear_flag(channel, CF_CONFERENCE); + switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE); switch_core_session_video_reset(session); } diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 5f8386505e..3eb9852e20 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -229,6 +229,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } } + if (status == SWITCH_STATUS_INUSE) { + *frame = &runtime.dummy_cng_frame; + switch_yield(20000); + return SWITCH_STATUS_SUCCESS; + } + if (!SWITCH_READ_ACCEPTABLE(status) || !session->read_codec || !switch_core_codec_ready(session->read_codec)) { *frame = NULL; return SWITCH_STATUS_FALSE; diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 2d18266cb5..eccb0774ff 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -1231,14 +1231,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (switch_mutex_trylock(engine->read_mutex) != SWITCH_STATUS_SUCCESS) { /* return CNG, another thread is already reading */ - *frame = &engine->read_frame; - switch_set_flag((*frame), SFF_CNG); - (*frame)->datalen = engine->read_impl.encoded_bytes_per_packet; - memset((*frame)->data, 0, (*frame)->datalen); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being read for %s\n", switch_channel_get_name(session->channel), type2str(type)); - switch_yield(10000); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_INUSE; }