[vlc-commits] commit: stream_filter/httplive.c: reloading playlist check before download segments (Jean-Paul Saman )

git at videolan.org git at videolan.org
Fri Dec 31 17:55:47 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Fri Dec 31 15:31:49 2010 +0100| [c407725c0a6dd217458cb59bad342c4c02e20420] | committer: Jean-Paul Saman 

stream_filter/httplive.c: reloading playlist check before download segments

Rearrange hls_Thread logic with live playback in mind. In case all segments have been
downloaded, then make sure that reloading the playlist file happens before downloading
the next segment. This is also true when it is time to reload the playlist.

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

 modules/stream_filter/httplive.c |   57 ++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index ba2c87c..237eed4 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1206,14 +1206,15 @@ static void* hls_Thread(vlc_object_t *p_this)
         vlc_mutex_unlock(&hls->lock);
 
         /* Is there a new segment to process? */
-        if ((p_sys->playback.segment < (count - 6)) ||
+        if ((!p_sys->b_live && (p_sys->playback.segment < (count - 6))) ||
             (client->segment >= count))
         {
             /* wait */
             vlc_mutex_lock(&client->lock_wait);
             while (((client->segment - p_sys->playback.segment > 6) ||
                     (client->segment >= count)) &&
-                   (client->seek == -1))
+                   (client->seek == -1) &&
+                   (mdate() < p_sys->playlist.wakeup))
             {
                 vlc_cond_wait(&client->wait, &client->lock_wait);
                 if (!vlc_object_alive(p_this)) break;
@@ -1229,6 +1230,32 @@ static void* hls_Thread(vlc_object_t *p_this)
 
         if (!vlc_object_alive(p_this)) break;
 
+        /* reload the m3u8 index file */
+        if (p_sys->b_live)
+        {
+            double wait = 1;
+            mtime_t now = mdate();
+            if (now >= p_sys->playlist.wakeup)
+            {
+                if (hls_ReloadPlaylist(client->s) != VLC_SUCCESS)
+                {
+                    /* No change in playlist, then backoff */
+                    p_sys->playlist.tries++;
+                    if (p_sys->playlist.tries == 1) wait = 0.5;
+                    else if (p_sys->playlist.tries == 2) wait = 1;
+                    else if (p_sys->playlist.tries >= 3) wait = 3;
+                }
+                else p_sys->playlist.tries = 0;
+
+                /* determine next time to update playlist */
+                p_sys->playlist.last = now;
+                p_sys->playlist.wakeup = now + ((mtime_t)(hls->duration * wait)
+                                                * (mtime_t)1000000);
+            }
+
+            if (!vlc_object_alive(p_this)) break;
+        }
+
         vlc_mutex_lock(&hls->lock);
         segment_t *segment = segment_GetSegment(hls, client->segment);
         assert(segment);
@@ -1236,6 +1263,8 @@ static void* hls_Thread(vlc_object_t *p_this)
 
         if (Download(client->s, hls, segment, &client->current) != VLC_SUCCESS)
         {
+            if (!vlc_object_alive(p_this)) break;
+
             if (!p_sys->b_live)
             {
                 p_sys->b_error = true;
@@ -1255,30 +1284,6 @@ static void* hls_Thread(vlc_object_t *p_this)
             client->segment++;
         vlc_cond_signal(&client->wait);
         vlc_mutex_unlock(&client->lock_wait);
-
-        /* reload the m3u8 index file */
-        if (p_sys->b_live)
-        {
-            double wait = 1;
-            mtime_t now = mdate();
-            if (now >= p_sys->playlist.wakeup)
-            {
-                if (hls_ReloadPlaylist(client->s) != VLC_SUCCESS)
-                {
-                    /* No change in playlist, then backoff */
-                    p_sys->playlist.tries++;
-                    if (p_sys->playlist.tries == 1) wait = 0.5;
-                    else if (p_sys->playlist.tries == 2) wait = 1;
-                    else if (p_sys->playlist.tries >= 3) wait = 3;
-                }
-                else p_sys->playlist.tries = 0;
-
-                /* determine next time to update playlist */
-                p_sys->playlist.last = now;
-                p_sys->playlist.wakeup = now + ((mtime_t)(hls->duration * wait)
-                                                * (mtime_t)1000000);
-            }
-        }
     }
 
     vlc_restorecancel(canc);



More information about the vlc-commits mailing list