[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
Mon Aug 26 15:43:07 CEST 2013


vlc | branch: master | Avishay Spitzer <savishay at gmail.com> | Wed Aug 14 04:08:01 2013 -0400| [a9498addb2e41c0584a87c00c71add35be0b3a36] | committer: Ilkka Ollakka

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>

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

 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 0512516..cc1c0b7 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1341,7 +1341,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);
 
@@ -1418,6 +1418,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;
         }
     }
 
@@ -1434,6 +1437,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;
@@ -1469,12 +1475,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