gst/apetag/gsttagdemux.c: Fix handling of -1 values for start and stop values when...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 12 Mar 2007 17:56:54 +0000 (17:56 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 12 Mar 2007 17:56:54 +0000 (17:56 +0000)
Original commit message from CVS:
* gst/apetag/gsttagdemux.c: (gst_tag_demux_srcpad_event):
Fix handling of -1 values for start and stop values when seeking,
and SEEK_CUR+SEEK_END here as well.

ChangeLog
gst/apetag/gsttagdemux.c

index 3e66d66..899edf3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-12  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/apetag/gsttagdemux.c: (gst_tag_demux_srcpad_event):
+         Fix handling of -1 values for start and stop values when seeking,
+         and SEEK_CUR+SEEK_END here as well.
+
 2007-03-12  Jan Schmidt  <thaytan@mad.scientist.com>
 
        * gst/id3demux/gstid3demux.c: (gst_id3demux_srcpad_event):
index 9baaebb..b8560b9 100644 (file)
@@ -732,12 +732,18 @@ gst_tag_demux_srcpad_event (GstPad * pad, GstEvent * event)
 
         switch (cur_type) {
           case GST_SEEK_TYPE_SET:
+            if (cur == -1)
+              cur = 0;
             cur += tagdemux->priv->strip_start;
             break;
           case GST_SEEK_TYPE_CUR:
             break;
           case GST_SEEK_TYPE_END:
-            cur += tagdemux->priv->strip_end;
+            /* Adjust the seek to be relative to the start of any end tag
+             * (note: 10 bytes before end is represented by stop=-10) */
+            if (cur > 0)
+              cur = 0;
+            cur -= tagdemux->priv->strip_end;
             break;
           default:
             g_assert_not_reached ();
@@ -745,12 +751,19 @@ gst_tag_demux_srcpad_event (GstPad * pad, GstEvent * event)
         }
         switch (stop_type) {
           case GST_SEEK_TYPE_SET:
-            stop += tagdemux->priv->strip_start;
+            if (stop != -1) {
+              /* -1 means the end of the file, pass it upstream intact */
+              stop += tagdemux->priv->strip_start;
+            }
             break;
           case GST_SEEK_TYPE_CUR:
             break;
           case GST_SEEK_TYPE_END:
-            stop += tagdemux->priv->strip_end;
+            /* Adjust the seek to be relative to the start of any end tag
+             * (note: 10 bytes before end is represented by stop=-10) */
+            if (stop > 0)
+              stop = 0;
+            stop -= tagdemux->priv->strip_end;
             break;
           default:
             break;