matroskademux: improve stream synchronization
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Thu, 28 Jan 2010 17:58:08 +0000 (18:58 +0100)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Tue, 2 Feb 2010 15:54:05 +0000 (16:54 +0100)
In particular, do not make it send newsegment updates that
sort-of contradict the indented playback segment (e.g. start time).

gst/matroska/matroska-demux.c

index 4ed380a..9448b97 100644 (file)
@@ -3526,9 +3526,12 @@ gst_matroska_demux_sync_streams (GstMatroskaDemux * demux)
         "Checking for resync on stream %d (%" GST_TIME_FORMAT ")", stream_nr,
         GST_TIME_ARGS (context->pos));
 
-    /* does it lag? 0.5 seconds is a random threshold... */
-    if (GST_CLOCK_TIME_IS_VALID (context->pos)
-        && context->pos + (GST_SECOND / 2) < demux->segment.last_stop) {
+    /* does it lag? 0.5 seconds is a random threshold...
+     * lag need only be considered if we have advanced into requested segment */
+    if (GST_CLOCK_TIME_IS_VALID (context->pos) &&
+        GST_CLOCK_TIME_IS_VALID (demux->segment.last_stop) &&
+        demux->segment.last_stop > demux->segment.start &&
+        context->pos + (GST_SECOND / 2) < demux->segment.last_stop) {
       GST_DEBUG_OBJECT (demux,
           "Synchronizing stream %d with others by advancing time " "from %"
           GST_TIME_FORMAT " to %" GST_TIME_FORMAT, stream_nr,