[vlc-devel] [PATCH] HLS: Wait for segment to be available

Frederic YHUEL fyhuel at viotech.net
Fri Apr 20 17:12:29 CEST 2012


2012/4/16 Frédéric Yhuel <fyhuel at viotech.net>:
> Without this patch the playback could stop if the available bandwidth
> is more or less equal to the lowest stream bitrate. With this patch,
> the user might experience a few "freezes" at the begining and then
> smooth playback afterwards.
> ---
>  modules/stream_filter/httplive.c |   23 ++++++++++++++++++++++-
>  1 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
> index e1e533a..3e41add 100644
> --- a/modules/stream_filter/httplive.c
> +++ b/modules/stream_filter/httplive.c
> @@ -2109,6 +2109,24 @@ check:
>     return segment;
>  }
>
> +static segment_t *WaitForSegment(stream_t *s)
> +{
> +    stream_sys_t *p_sys = s->p_sys;
> +
> +    segment_t *segment = GetSegment(s);
> +    vlc_mutex_lock(&p_sys->download.lock_wait);
> +    while (segment == NULL)
> +    {
> +        if (p_sys->b_error)
> +            break;
> +        vlc_cond_wait(&p_sys->download.wait, &p_sys->download.lock_wait);
> +        segment = GetSegment(s);
> +    }
> +    vlc_mutex_unlock(&p_sys->download.lock_wait);
> +
> +    return segment;
> +}
> +

Humm... actually I think that something like:

    static segment_t *WaitForSegment(stream_t *s)
    {
        stream_sys_t *p_sys = s->p_sys;

        segment_t *segment = GetSegment(s);
        vlc_mutex_lock(&p_sys->download.lock_wait);
        while (segment == NULL)
        {
            if (p_sys->b_error || !vlc_object_alive(s))
                break;
            vlc_cond_timedwait(&p_sys->download.wait,
                    &p_sys->download.lock_wait, 100000 );
            segment = GetSegment(s);
        }
        vlc_mutex_unlock(&p_sys->download.lock_wait);

        return segment;
    }


would be more appropriate. Otherwise it freezes once the playback is finished.

What do you think?

Best Regards,

-- 
Frédéric



More information about the vlc-devel mailing list