From: Anthony Minessale Date: Thu, 18 Jun 2015 20:57:21 +0000 (-0500) Subject: FS-7656 fix a/v sync on first connection (retry 1) X-Git-Tag: v1.6.2~432 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a0bbc45433dc4f01f310dc23bf2701212f8f425;p=thirdparty%2Ffreeswitch.git FS-7656 fix a/v sync on first connection (retry 1) --- diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index afbb31532c..903db6506c 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -333,10 +333,15 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void used = switch_buffer_read(audio_buffer, dist_buf, source->samples * 2 * source->channels); if (!source->total) { + switch_mutex_lock(source->mutex); + while (switch_queue_trypop(source->video_q, &pop) == SWITCH_STATUS_SUCCESS) { switch_image_t *img = (switch_image_t *) pop; switch_img_free(&img); } + + switch_mutex_unlock(source->mutex); + } else { uint32_t bused = 0; @@ -366,7 +371,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void } switch_mutex_unlock(source->mutex); - + switch_mutex_lock(source->mutex); while (switch_queue_trypop(source->video_q, &pop) == SWITCH_STATUS_SUCCESS) { switch_image_t *img = (switch_image_t *) pop; switch_image_t *imgcp = NULL; @@ -375,7 +380,6 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void switch_queue_push(source->context_list->video_q, img); } else { if (source->context_list) { - switch_mutex_lock(source->mutex); for (cp = source->context_list; cp && RUNNING; cp = cp->next) { if (cp->video_q) { imgcp = NULL; @@ -385,11 +389,12 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void } } } - switch_mutex_unlock(source->mutex); } switch_img_free(&img); } } + switch_mutex_unlock(source->mutex); + } } }