baseparse: fix reverse playback handling
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Fri, 10 Dec 2010 14:59:49 +0000 (15:59 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 8 Apr 2011 14:44:54 +0000 (15:44 +0100)
gst/audioparsers/gstbaseparse.c

index 1dee034..aee1c9a 100644 (file)
@@ -2153,11 +2153,17 @@ gst_base_parse_handle_previous_fragment (GstBaseParse * parse)
   if (ret != GST_FLOW_OK)
     goto exit;
 
+  /* offset will increase again as fragment is processed/parsed */
+  parse->priv->last_offset = offset;
+
   gst_adapter_push (parse->adapter, buffer);
   ret = gst_base_parse_process_fragment (parse, FALSE);
   if (ret != GST_FLOW_OK)
     goto exit;
 
+  /* force previous fragment */
+  parse->priv->offset = -1;
+
 exit:
   return ret;
 }
@@ -2275,7 +2281,9 @@ gst_base_parse_loop (GstPad * pad)
    * first fragment (closest to stop time) is handled normally below,
    * then we pull in fragments going backwards */
   if (parse->segment.rate < 0.0) {
-    if (GST_CLOCK_TIME_IS_VALID (parse->priv->last_ts)) {
+    /* check if we jumped back to a previous fragment,
+     * which is a post-first fragment */
+    if (parse->priv->offset < 0) {
       ret = gst_base_parse_handle_previous_fragment (parse);
       goto done;
     }
@@ -2294,6 +2302,8 @@ gst_base_parse_loop (GstPad * pad)
     GST_DEBUG_OBJECT (parse, "downstream has reached end of segment");
     /* push what was accumulated during loop run */
     gst_base_parse_process_fragment (parse, TRUE);
+    /* force previous fragment */
+    parse->priv->offset = -1;
     ret = GST_FLOW_OK;
   }