]> git.sesse.net Git - vlc/commitdiff
In case of live streams, the reload thread did not wake up the download thread and...
authorAvishay Spitzer <savishay@gmail.com>
Wed, 14 Aug 2013 08:08:01 +0000 (04:08 -0400)
committerIlkka Ollakka <ileoo@videolan.org>
Mon, 26 Aug 2013 13:39:49 +0000 (16:39 +0300)
Signed-off-by: Ilkka Ollakka <ileoo@videolan.org>
modules/stream_filter/httplive.c

index 0512516eb3f3d6e49b05be00b42eaf218a4619e8..cc1c0b73d99ee3a7d2740cd9e41934e2ba73dd99 100644 (file)
@@ -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;
 }