From: Jean-Paul Saman Date: Fri, 17 Dec 2010 14:44:42 +0000 (+0100) Subject: stream_filter/httplive.c: do not seek in last 3 segments of HLS stream X-Git-Tag: 1.2.0-pre1~4245 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=cc8181c8095d5344b5013bb3418f21781f6a9831;p=vlc stream_filter/httplive.c: do not seek in last 3 segments of HLS stream Seeking into the last 3 segments keeps this condition in false state. In this case it should turn into true because the last 3 segments have already been downloaded. Or the condition should just not be applied. --- diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c index 1815d9efa3..bb62be4630 100644 --- a/modules/stream_filter/httplive.c +++ b/modules/stream_filter/httplive.c @@ -1574,14 +1574,20 @@ static int segment_Seek(stream_t *s, uint64_t pos) vlc_mutex_lock(&segment->lock); length += segment->duration * (hls->bandwidth/8); + vlc_mutex_unlock(&segment->lock); if (!b_found && (pos <= length)) { - count = p_sys->segment; - p_sys->segment = n; - b_found = true; + if (count - n >= 3) + { + p_sys->segment = n; + b_found = true; + break; + } + /* Do not search in last 3 segments */ + vlc_mutex_unlock(&hls->lock); + return VLC_EGENERIC; } - vlc_mutex_unlock(&segment->lock); } /* */ @@ -1626,9 +1632,12 @@ static int segment_Seek(stream_t *s, uint64_t pos) while ((p_sys->thread->seek != -1) || (p_sys->thread->segment - p_sys->segment < 3)) { + /* FIXME: This never finishes when the download thread is + * at its end and the user searches to a segment within the + * last three segments. In that case it should just count the + * segment as being available. */ vlc_cond_wait(&p_sys->thread->wait, &p_sys->thread->lock_wait); - if (!vlc_object_alive (s) || - s->b_error) break; + if (!vlc_object_alive(s) || s->b_error) break; } vlc_mutex_unlock(&p_sys->thread->lock_wait);