[vlc-commits] In case of live streams, the reload thread did not wake up the download thread and so new segments were not downloaded. Problem was fixed by sginalling the download thread with the condition variable.

Avishay Spitzer git at videolan.org
Tue Aug 27 14:41:57 CEST 2013


vlc/vlc-2.1 | branch: master | Avishay Spitzer <savishay at gmail.com> | Wed Aug 14 04:08:01 2013 -0400| [e93de6669e4a5b693b0f2b485a5a97fcdac993ac] | committer: Jean-Baptiste Kempf

In case of live streams, the reload thread did not wake up the download thread and so new segments were not downloaded. Problem was fixed by sginalling the download thread with the condition variable.

Signed-off-by: Ilkka Ollakka <ileoo at videolan.org>
(cherry picked from commit a9498addb2e41c0584a87c00c71add35be0b3a36)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_filter/httplive.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 59d712a..3424c13 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1343,7 +1343,7 @@ static int get_HTTPLiveMetaPlaylist(stream_t *s, vlc_array_t **streams)
 
 /* Update hls_old (an existing member of p_sys->hls_stream) to match hls_new
    (which represents a downloaded, perhaps newer version of the same playlist) */
-static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *hls_old)
+static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *hls_old, bool *stream_appended)
 {
     int count = vlc_array_count(hls_new->segments);
 
@@ -1420,6 +1420,9 @@ static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *
             }
             vlc_array_append(hls_old->segments, p);
             msg_Info(s, "- segment %d appended", p->sequence);
+
+            // Signal download thread otherwise the segment will not get downloaded
+            *stream_appended = true;
         }
     }
 
@@ -1436,6 +1439,9 @@ static int hls_ReloadPlaylist(stream_t *s)
 {
     stream_sys_t *p_sys = s->p_sys;
 
+    // Flag to indicate if we should signal download thread
+    bool stream_appended = false;
+
     vlc_array_t *hls_streams = vlc_array_new();
     if (hls_streams == NULL)
         return VLC_ENOMEM;
@@ -1471,12 +1477,24 @@ static int hls_ReloadPlaylist(stream_t *s)
             vlc_array_append(p_sys->hls_stream, hls_new);
             msg_Info(s, "new HLS stream appended (id=%d, bandwidth=%"PRIu64")",
                      hls_new->id, hls_new->bandwidth);
+
+            // New segment available -  signal download thread
+            stream_appended = true;
         }
-        else if (hls_UpdatePlaylist(s, hls_new, hls_old) != VLC_SUCCESS)
+        else if (hls_UpdatePlaylist(s, hls_new, hls_old, &stream_appended) != VLC_SUCCESS)
             msg_Info(s, "failed updating HLS stream (id=%d, bandwidth=%"PRIu64")",
                      hls_new->id, hls_new->bandwidth);
     }
     vlc_array_destroy(hls_streams);
+
+    // Must signal the download thread otherwise new segments will not be downloaded at all!
+    if (stream_appended == true)
+    {
+	vlc_mutex_lock(&p_sys->download.lock_wait);
+	vlc_cond_signal(&p_sys->download.wait);
+	vlc_mutex_unlock(&p_sys->download.lock_wait);
+    }
+
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list