[vlc-devel] [PATCH 1/1] Fixed expansive loop when there is a clock gap

Rémi Denis-Courmont remi at remlab.net
Thu Oct 19 19:57:56 CEST 2017


Le torstaina 12. lokakuuta 2017, 16.38.02 EEST Jérémy VIGNELLES a écrit :
> ---
>  modules/stream_out/cycle.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/modules/stream_out/cycle.c b/modules/stream_out/cycle.c
> index bb031f81ae..a76d2af46d 100644
> --- a/modules/stream_out/cycle.c
> +++ b/modules/stream_out/cycle.c
> @@ -155,13 +155,26 @@ static int Send(sout_stream_t *stream,
> sout_stream_id_sys_t *id, block_t *block)
>  {
>      sout_stream_sys_t *sys = stream->p_sys;
> -
> +    mtime_t block_clock;
>      for (block_t *next = block->p_next; block != NULL; block = next)
>      {
>          block->p_next = NULL;
> 
>          /* FIXME: deal with key frames properly */
> -        while (sys->clock(block) >= sys->next->offset)
> +        block_clock = sys->clock(block);
> +	if (block_clock >= sys->next->offset + sys->period)
> +	{
> +	    // Clock gap! More than 1 complete cycle can be run
> +	    mtime_t adjust_offset = ((block_clock - sys->next->offset) /
> sys->period) * sys->period;
> +	    msg_Dbg(stream, "Clock gap of more that
> %llu cycle detected, fast-forwarding cycles", (block_clock -
> sys->next->offset) / sys->period);
> +	    // Adjust all offsets
> +	    for(sout_cycle_t* cycle=sys->start;cycle != NULL; cycle = cycle->next)
> +	    {
> +                cycle->offset += adjust_offset;
> +	    }
> +	}
> +
> +	while (block_clock >= sys->next->offset)
>          {
>              DelStream(stream);
>              AddStream(stream, sys->next->chain);

AFAICT, this only solves the problem in the simple degenerate case.

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list