[vlc-commits] stream_filter: httplive: fix delay on eof

Francois Cartegnie git at videolan.org
Mon Apr 27 15:16:08 CEST 2015


vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Apr 23 15:31:58 2015 +0200| [af1782beffd1a9b365a6189d5e18ed5ed1cc1892] | committer: Jean-Baptiste Kempf

stream_filter: httplive: fix delay on eof

(cherry picked from commit 169604c5a75b4d9f99a1db8561e6319d6b11bbfb)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=af1782beffd1a9b365a6189d5e18ed5ed1cc1892
---

 modules/stream_filter/httplive.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 45f908a..e94dad5 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -155,6 +155,7 @@ struct stream_sys_t
     vlc_mutex_t  lock;
     bool         paused;
     atomic_bool  closing;
+    atomic_bool  eof;
 };
 
 /****************************************************************************
@@ -1661,6 +1662,13 @@ static void* hls_Thread(void *p_this)
                     (p_sys->download.segment >= count)) &&
                    (p_sys->download.seek == -1))
             {
+
+                if(!p_sys->b_live && p_sys->download.segment >= count)
+                {
+                    /* this was last segment to read */
+                    atomic_store(&p_sys->eof, true);
+                }
+
                 vlc_cond_wait(&p_sys->download.wait, &p_sys->download.lock_wait);
                 if (p_sys->b_live /*&& (mdate() >= p_sys->playlist.wakeup)*/)
                     break;
@@ -1672,6 +1680,7 @@ static void* hls_Thread(void *p_this)
             {
                 p_sys->download.segment = p_sys->download.seek;
                 p_sys->download.seek = -1;
+                atomic_store(&p_sys->eof, false);
             }
 
             vlc_mutex_unlock(&p_sys->download.lock_wait);
@@ -2065,6 +2074,7 @@ static int Open(vlc_object_t *p_this)
 
     p_sys->paused = false;
     atomic_init(&p_sys->closing, false);
+    atomic_init(&p_sys->eof, false);
 
     vlc_cond_init(&p_sys->wait);
     vlc_mutex_init(&p_sys->lock);
@@ -2420,6 +2430,12 @@ static int Read(stream_t *s, void *buffer, unsigned int i_read)
         // running this read operation is also responsible for closing the stream
         if (length == 0)
         {
+            if(atomic_load(&p_sys->eof)) /* finished reading last segment */
+            {
+                vlc_mutex_unlock(&p_sys->read.lock_wait);
+                return 0;
+            }
+
             mtime_t start = mdate();
 
             // Wait for 10 seconds



More information about the vlc-commits mailing list