Commit 1555e3ce authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

hls: Don't download the same segment twice when prefetching.

This makes the playback start faster.
parent c0b3a6f1
...@@ -1724,35 +1724,21 @@ static void* hls_Reload(void *p_this) ...@@ -1724,35 +1724,21 @@ static void* hls_Reload(void *p_this)
static int Prefetch(stream_t *s, int *current) static int Prefetch(stream_t *s, int *current)
{ {
stream_sys_t *p_sys = s->p_sys; stream_sys_t *p_sys = s->p_sys;
int stream; int stream = *current;
/* Try to pick best matching stream */; hls_stream_t *hls = hls_Get(p_sys->hls_stream, stream);
again:
stream = *current;
hls_stream_t *hls = hls_Get(p_sys->hls_stream, *current);
if (hls == NULL) if (hls == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
if (segment == NULL )
return VLC_EGENERIC;
if (hls_DownloadSegmentData(s, hls, segment, current) != VLC_SUCCESS)
return VLC_EGENERIC;
/* Found better bandwidth match, try again */
if (*current != stream)
goto again;
/* Download first 2 segments of this HLS stream */ /* Download first 2 segments of this HLS stream */
stream = *current;
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
segment_t *segment = segment_GetSegment(hls, p_sys->download.segment); segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
if (segment == NULL ) if (segment == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
/* It is useless to lock the segment here, as Prefetch is called before
download and playlit thread are started. */
if (segment->data) if (segment->data)
{ {
p_sys->download.segment++; p_sys->download.segment++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment