/* 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);
}
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;
}
}
{
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;
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;
}