Commit af1782be authored by Francois Cartegnie's avatar Francois Cartegnie Committed by Jean-Baptiste Kempf

stream_filter: httplive: fix delay on eof

(cherry picked from commit 169604c5a75b4d9f99a1db8561e6319d6b11bbfb)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4ddbb29d
...@@ -155,6 +155,7 @@ struct stream_sys_t ...@@ -155,6 +155,7 @@ struct stream_sys_t
vlc_mutex_t lock; vlc_mutex_t lock;
bool paused; bool paused;
atomic_bool closing; atomic_bool closing;
atomic_bool eof;
}; };
/**************************************************************************** /****************************************************************************
...@@ -1661,6 +1662,13 @@ static void* hls_Thread(void *p_this) ...@@ -1661,6 +1662,13 @@ static void* hls_Thread(void *p_this)
(p_sys->download.segment >= count)) && (p_sys->download.segment >= count)) &&
(p_sys->download.seek == -1)) (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); vlc_cond_wait(&p_sys->download.wait, &p_sys->download.lock_wait);
if (p_sys->b_live /*&& (mdate() >= p_sys->playlist.wakeup)*/) if (p_sys->b_live /*&& (mdate() >= p_sys->playlist.wakeup)*/)
break; break;
...@@ -1672,6 +1680,7 @@ static void* hls_Thread(void *p_this) ...@@ -1672,6 +1680,7 @@ static void* hls_Thread(void *p_this)
{ {
p_sys->download.segment = p_sys->download.seek; p_sys->download.segment = p_sys->download.seek;
p_sys->download.seek = -1; p_sys->download.seek = -1;
atomic_store(&p_sys->eof, false);
} }
vlc_mutex_unlock(&p_sys->download.lock_wait); vlc_mutex_unlock(&p_sys->download.lock_wait);
...@@ -2065,6 +2074,7 @@ static int Open(vlc_object_t *p_this) ...@@ -2065,6 +2074,7 @@ static int Open(vlc_object_t *p_this)
p_sys->paused = false; p_sys->paused = false;
atomic_init(&p_sys->closing, false); atomic_init(&p_sys->closing, false);
atomic_init(&p_sys->eof, false);
vlc_cond_init(&p_sys->wait); vlc_cond_init(&p_sys->wait);
vlc_mutex_init(&p_sys->lock); vlc_mutex_init(&p_sys->lock);
...@@ -2420,6 +2430,12 @@ static int Read(stream_t *s, void *buffer, unsigned int i_read) ...@@ -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 // running this read operation is also responsible for closing the stream
if (length == 0) 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(); mtime_t start = mdate();
// Wait for 10 seconds // Wait for 10 seconds
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment