From 5ac63b92506110c8d6af09c3837f956bcc05b3d3 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Tue, 3 Mar 2015 11:48:56 -0600
Subject: [PATCH] FS-7514: pop only newest frame on video file read to keep
 sync

---
 src/mod/formats/mod_vlc/mod_vlc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/mod/formats/mod_vlc/mod_vlc.c b/src/mod/formats/mod_vlc/mod_vlc.c
index 3a8cdb6d74..cc95c39121 100644
--- a/src/mod/formats/mod_vlc/mod_vlc.c
+++ b/src/mod/formats/mod_vlc/mod_vlc.c
@@ -1025,6 +1025,14 @@ static switch_status_t vlc_file_read_video(switch_file_handle_t *handle, switch_
 		return SWITCH_STATUS_FALSE;
 	}
 	
+	while(switch_queue_size(vcontext->video_queue) > 1) {
+		if (switch_queue_trypop(vcontext->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+			switch_image_t *img = (switch_image_t *) pop;
+			switch_img_free(&img);
+		}
+	}
+
+	
 	if (switch_queue_pop(vcontext->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 		if (!pop) {
 			vcontext->err = 1;