matroskademux: Advance sparse streams only as much as required to keep the gap smalle...
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 26 Feb 2010 17:10:32 +0000 (18:10 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 27 Feb 2010 11:20:06 +0000 (12:20 +0100)
Changing it to the newest timestamp that was ever pushed will
increase the segment start in 500ms jumps, which could be just
after the next sparse stream buffer. E.g.

Video at 1.0s, sparse stream at 0.5s would jump the
sparse stream to 1.0s. Now a new sparse stream buffer could
appear that has a timestamp of 0.9s and this would be
dropped for no good reason because of bad luck.

gst/matroska/matroska-demux.c

index 5f2d10b..de0fc43 100644 (file)
@@ -3532,19 +3532,21 @@ gst_matroska_demux_sync_streams (GstMatroskaDemux * demux)
         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) {
+      gint64 new_start;
+
+      new_start = demux->segment.last_stop - (GST_SECOND / 2);
       GST_DEBUG_OBJECT (demux,
           "Synchronizing stream %d with others by advancing time " "from %"
           GST_TIME_FORMAT " to %" GST_TIME_FORMAT, stream_nr,
-          GST_TIME_ARGS (context->pos),
-          GST_TIME_ARGS (demux->segment.last_stop));
+          GST_TIME_ARGS (context->pos), GST_TIME_ARGS (new_start));
 
-      context->pos = demux->segment.last_stop;
+      context->pos = new_start;
 
       /* advance stream time */
       gst_pad_push_event (context->pad,
           gst_event_new_new_segment (TRUE, demux->segment.rate,
-              demux->segment.format, demux->segment.last_stop,
-              demux->segment.stop, demux->segment.last_stop));
+              demux->segment.format, new_start,
+              demux->segment.stop, new_start));
     }
   }
 }