FS-10050 cont fix some mem issues with playing files and ignoring the audio
This commit is contained in:
parent
888c8f96fa
commit
dcbd39cc26
|
@ -1457,9 +1457,7 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo
|
|||
switch_buffer_zero(context->audio_buffer);
|
||||
switch_mutex_unlock(context->mutex);
|
||||
|
||||
if (context->eh.video_queue) {
|
||||
flush_video_queue(context->eh.video_queue, 0);
|
||||
}
|
||||
|
||||
|
||||
// if (context->has_audio) stream_id = context->audio_st.st->index;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "seeking to %" SWITCH_INT64_T_FMT "\n", context->seek_ts);
|
||||
|
@ -1475,12 +1473,18 @@ 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);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
|
@ -2161,7 +2165,6 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
|||
|
||||
|
||||
if (!context->has_video || context->closed) return SWITCH_STATUS_FALSE;
|
||||
|
||||
if ((flags & SVR_CHECK)) {
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
|
@ -2185,10 +2188,13 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
|||
|
||||
frame->img = (switch_image_t *) pop;
|
||||
|
||||
if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
|
||||
if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
|
||||
switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
|
||||
if (frame->img) {
|
||||
if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
|
||||
if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
|
||||
switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
|
||||
}
|
||||
}
|
||||
context->vid_ready = 1;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -2386,6 +2392,11 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
|||
}
|
||||
|
||||
if (frame->img) {
|
||||
if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
|
||||
if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
|
||||
switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
|
||||
}
|
||||
}
|
||||
context->vid_ready = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ SWITCH_MODULE_DEFINITION(mod_video_filter, mod_video_filter_load, mod_video_filt
|
|||
typedef struct chromakey_context_s {
|
||||
int threshold;
|
||||
switch_image_t *bgimg;
|
||||
switch_image_t *backup_img;
|
||||
switch_image_t *bgimg_scaled;
|
||||
switch_file_handle_t vfh;
|
||||
switch_rgb_color_t bgcolor;
|
||||
|
@ -192,7 +193,10 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_mutex_lock(context->command_mutex);
|
||||
if (switch_mutex_trylock(context->command_mutex) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_img_patch(frame->img, context->backup_img, 0, 0);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
data = malloc(frame->img->d_w * frame->img->d_h * 4);
|
||||
switch_assert(data);
|
||||
|
@ -257,6 +261,8 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
|||
}
|
||||
|
||||
switch_img_patch(frame->img, img, 0, 0);
|
||||
switch_img_free(&context->backup_img);
|
||||
switch_img_copy(frame->img, &context->backup_img);
|
||||
switch_img_free(&img);
|
||||
free(data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue