From abd75456086d87ea3ad44ba5bd2fe424062df201 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 18 May 2017 13:42:40 -0500 Subject: [PATCH] FS-10326: [mod_conference] Memory leak while playing video files that contain only a video stream #resolve --- src/mod/applications/mod_av/avformat.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c index efadc87708..7de6dfd3fd 100644 --- a/src/mod/applications/mod_av/avformat.c +++ b/src/mod/applications/mod_av/avformat.c @@ -1543,10 +1543,6 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo vid_frames = switch_queue_size(context->eh.video_queue); } - if (vid_frames > context->read_fps) { - switch_yield(250000); - } - if (switch_buffer_inuse(context->audio_buffer) > AUDIO_BUF_SEC * context->audio_st.sample_rate * context->audio_st.channels * 2 && (!context->has_video || vid_frames > 5)) { switch_yield(context->has_video ? 1000 : 10000); @@ -1683,6 +1679,9 @@ again: context->vid_ready = 1; switch_queue_push(context->eh.video_queue, img); context->last_vid_push = switch_time_now(); + + + } } } @@ -1830,7 +1829,7 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa } if (context->has_video) { - switch_queue_create(&context->eh.video_queue, SWITCH_CORE_QUEUE_LEN, handle->memory_pool); + switch_queue_create(&context->eh.video_queue, context->read_fps, handle->memory_pool); switch_mutex_init(&context->eh.mutex, SWITCH_MUTEX_NESTED, handle->memory_pool); switch_core_timer_init(&context->video_timer, "soft", 66, 1, context->pool); } @@ -2143,7 +2142,9 @@ static switch_status_t av_file_close(switch_file_handle_t *handle) context->eh.finalize = 1; if (context->eh.video_queue) { + flush_video_queue(context->eh.video_queue, 0); switch_queue_push(context->eh.video_queue, NULL); + switch_queue_term(context->eh.video_queue); } if (context->eh.video_thread) { @@ -2163,10 +2164,6 @@ static switch_status_t av_file_close(switch_file_handle_t *handle) context->file_read_thread = NULL; } - if (context->eh.video_queue) { - flush_video_queue(context->eh.video_queue, 0); - } - if (context->fc) { if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) av_write_trailer(context->fc);