[vlc-devel] [PATCH 10/48] hls: Wait for segment in peek
Jean-Paul Saman
jpsaman at videolan.org
Tue Jan 10 12:57:04 CET 2012
On Mon, Jan 9, 2012 at 4:16 PM, Hugo Beauzée-Luyssen <beauze.h at gmail.com> wrote:
> From: Luc Saillard <luc.saillard at sfr.com>
>
> ---
> modules/stream_filter/httplive.c | 34 +++++++++++++++++++++++++++++-----
> 1 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
> index ecddc01..3f0a7f4 100644
> --- a/modules/stream_filter/httplive.c
> +++ b/modules/stream_filter/httplive.c
> @@ -2,6 +2,7 @@
> * httplive.c: HTTP Live Streaming stream filter
> *****************************************************************************
> * Copyright (C) 2010-2011 M2X BV
> + * Copyright (C) 2004-2011 the VideoLAN team
The above line is wrong. You cannot assign copyright to VideoLAN
without permission from the original author(s).
> * $Id$
> *
> * Author: Jean-Paul Saman <jpsaman _AT_ videolan _DOT_ org>
> @@ -1579,10 +1580,8 @@ static void* hls_Thread(void *p_this)
> (p_sys->download.seek == -1))
> {
> vlc_cond_wait(&p_sys->download.wait, &p_sys->download.lock_wait);
> - if (p_sys->b_live /*&& (mdate() >= p_sys->playlist.wakeup)*/)
> - break;
> - if (!vlc_object_alive(s))
> - break;
> + if (!vlc_object_alive(s)) break;
> + if (p_sys->b_live) break;
The above 2 lines have nothing to do with the subject of the patch. It
is mere cleanup. Please separate into another patch.
> }
> /* */
> if (p_sys->download.seek >= 0)
> @@ -2244,12 +2243,37 @@ static int Peek(stream_t *s, const uint8_t **pp_peek, unsigned int i_peek)
> segment_t *segment;
> unsigned int len = i_peek;
>
> +again:
> + if (p_sys->b_reset)
> + {
> + msg_Err(s, "Please wait while closing stream... and reopen it");
> + char *original_playlist = strdup(p_sys->m3u8_playlist);
> + Close((vlc_object_t *)s);
> + OpenWithPlaylist(s, original_playlist);
> + free(original_playlist);
> + p_sys = s->p_sys;
> + }
> +
> segment = GetSegment(s);
> if (segment == NULL)
> {
> msg_Err(s, "segment %d should have been available (stream %d)",
> p_sys->playback.segment, p_sys->playback.stream);
> - return 0; /* eof? */
> +
> + msg_Info(s, "Waiting for segment to be downloaded");
> +
> + vlc_mutex_lock(&p_sys->download.lock_wait);
> +
> + /* wake up the download segment thread if blocked */
> + vlc_cond_signal(&p_sys->download.wait);
> +
> + mtime_t timeout = mdate() + 5000000;
> + if( vlc_cond_timedwait( &p_sys->download.wait, &p_sys->download.lock_wait, timeout ) )
> + msg_Warn(s, "Peek() reached timeout");
> + vlc_mutex_unlock(&p_sys->download.lock_wait);
> + if (!vlc_object_alive(s) || s->b_error)
> + return 0; /* eof? */
> + goto again;
> }
>
> vlc_mutex_lock(&segment->lock);
The above bit looks usefull. Please provide a new patch for this with
remarks from above addressed and do not forget to give a description
of the changes.
Kind regards,
Jean-Paul Saman.
> --
> 1.7.8.3
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list