[vlc-devel] [PATCH 1/1] Fixed expansive loop when there is a clock gap
Jérémy VIGNELLES
jeremy.vignelles at dev3i.fr
Thu Oct 12 16:38:02 CEST 2017
---
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);
--
2.11.0
More information about the vlc-devel
mailing list