From: Anthony Minessale Date: Sat, 10 Sep 2016 00:01:55 +0000 (-0500) Subject: FS-9498 #resolve [Try to make video writing thread more efficient] X-Git-Tag: v1.6.11~9^2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43c10074fba70dd4259537a3036becdab3354931;p=thirdparty%2Ffreeswitch.git FS-9498 #resolve [Try to make video writing thread more efficient] --- diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index ceaf12f8e7..96f3a98d16 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -1516,8 +1516,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_ conference_member_t *member = (conference_member_t *) obj; void *pop; switch_frame_t *frame; - int loops = 0; + int loops = 0, patched = 0; switch_time_t last = 0; + switch_status_t pop_status; if (switch_thread_rwlock_tryrdlock(member->rwlock) != SWITCH_STATUS_SUCCESS) { return NULL; @@ -1526,7 +1527,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_ //switch_core_autobind_cpu(); while(conference_utils_member_test_flag(member, MFLAG_RUNNING)) { - if (switch_queue_pop(member->mux_out_queue, &pop) == SWITCH_STATUS_SUCCESS) { + if (patched) { + pop_status = switch_queue_trypop(member->mux_out_queue, &pop); + } else { + pop_status = switch_queue_pop(member->mux_out_queue, &pop); + } + + if (pop_status == SWITCH_STATUS_SUCCESS) { mcu_layer_t *layer = NULL; mcu_canvas_t *canvas = NULL; @@ -1569,7 +1576,8 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_ canvas = NULL; layer = NULL; - + patched = 0; + switch_mutex_lock(member->conference->canvas_mutex); if (member->video_layer_id > -1 && member->canvas_id > -1) { canvas = member->conference->canvases[member->canvas_id]; @@ -1578,14 +1586,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_ if (layer->need_patch && switch_thread_rwlock_tryrdlock(canvas->video_rwlock) == SWITCH_STATUS_SUCCESS) { if (layer->need_patch) { conference_video_scale_and_patch(layer, NULL, SWITCH_FALSE); + patched++; layer->need_patch = 0; } switch_thread_rwlock_unlock(canvas->video_rwlock); } } switch_mutex_unlock(member->conference->canvas_mutex); - - } } diff --git a/src/switch_vpx.c b/src/switch_vpx.c index 9ad4ed8da5..6c7760ea53 100644 --- a/src/switch_vpx.c +++ b/src/switch_vpx.c @@ -1143,7 +1143,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t * //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, %d\n", context->no_key_frame); if (context->no_key_frame > 50) { if ((is_keyframe = is_start)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, treating start as key. frames=%d\n", context->no_key_frame); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "no keyframe, treating start as key. frames=%d\n", context->no_key_frame); } } }