Index: gsttheoradec.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ext/theora/gsttheoradec.h,v
retrieving revision 1.6
diff -u -r1.6 gsttheoradec.h
--- gsttheoradec.h	2 Nov 2006 15:06:36 -0000	1.6
+++ gsttheoradec.h	7 May 2007 11:26:36 -0000
@@ -63,6 +63,7 @@
   theora_comment comment;
 
   gboolean have_header;
+  gboolean sent_newsegment;
   guint64 granulepos;
   guint64 granule_shift;
 
@@ -82,6 +83,8 @@
   GList *gather;
   GList *decode;
 
+  GstTagList *tags;
+
   /* segment info */ /* with STREAM_LOCK */
   GstSegment segment;
   gboolean discont;
Index: theoradec.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ext/theora/theoradec.c,v
retrieving revision 1.89
diff -u -r1.89 theoradec.c
--- theoradec.c	13 Apr 2007 11:42:34 -0000	1.89
+++ theoradec.c	7 May 2007 11:26:36 -0000
@@ -172,6 +172,7 @@
 gst_theora_dec_reset (GstTheoraDec * dec)
 {
   dec->need_keyframe = TRUE;
+  dec->sent_newsegment = FALSE;
   dec->last_timestamp = -1;
   dec->granulepos = -1;
   dec->discont = TRUE;
@@ -192,6 +193,11 @@
   g_list_foreach (dec->decode, (GFunc) gst_mini_object_unref, NULL);
   g_list_free (dec->decode);
   dec->decode = NULL;
+
+  if (dec->tags) {
+    gst_tag_list_free (dec->tags);
+    dec->tags = NULL;
+  }
 }
 
 static int
@@ -689,8 +695,14 @@
       gst_segment_set_newsegment_full (&dec->segment, update,
           rate, arate, format, start, stop, time);
 
-      /* and forward */
-      ret = gst_pad_push_event (dec->srcpad, event);
+      /* iWe don't forward this unless/until the decoder is initialised */
+      if (dec->have_header) {
+        ret = gst_pad_push_event (dec->srcpad, event);
+        dec->sent_newsegment = TRUE;
+      } else {
+        gst_event_unref (event);
+        ret = TRUE;
+      }
       break;
     }
     default:
@@ -748,7 +760,7 @@
         GST_TAG_NOMINAL_BITRATE, dec->info.target_bitrate, NULL);
   }
 
-  gst_element_found_tags_for_pad (GST_ELEMENT_CAST (dec), dec->srcpad, list);
+  dec->tags = list;
 
   return GST_FLOW_OK;
 }
@@ -758,6 +770,8 @@
 {
   GstCaps *caps;
   gint par_num, par_den;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstEvent *event;
 
   GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d",
       dec->info.fps_numerator, dec->info.fps_denominator,
@@ -824,8 +838,24 @@
   gst_caps_unref (caps);
 
   dec->have_header = TRUE;
+  if (!dec->sent_newsegment) {
+    GST_DEBUG_OBJECT (dec, "Sending newsegment event");
+    
+    event = gst_event_new_new_segment_full (FALSE, 
+        dec->segment.rate, dec->segment.applied_rate, 
+        dec->segment.format, dec->segment.start, dec->segment.stop, 
+        dec->segment.time);
+    ret = gst_pad_push_event (dec->srcpad, event);
+    dec->sent_newsegment = TRUE;
+  }
 
-  return GST_FLOW_OK;
+  if (dec->tags) {
+    gst_element_found_tags_for_pad (GST_ELEMENT_CAST (dec), dec->srcpad, 
+        dec->tags);
+    dec->tags = NULL;
+  }
+
+  return ret;
 }
 
 static GstFlowReturn
@@ -1420,6 +1450,7 @@
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       theora_info_init (&dec->info);
       theora_comment_init (&dec->comment);
+      GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE in READY->PAUSED");
       dec->have_header = FALSE;
       gst_theora_dec_reset (dec);
       break;
