ext/spc/gstspc.c: Post an error and push EOS when we can't start playback for some...
authorJonathan Matthew <notverysmart@gmail.com>
Tue, 25 Nov 2008 18:28:18 +0000 (18:28 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 25 Nov 2008 18:28:18 +0000 (18:28 +0000)
Original commit message from CVS:
Patch by: Jonathan Matthew <notverysmart at gmail dot com>
* ext/spc/gstspc.c: (gst_spc_dec_sink_event), (spc_setup):
Post an error and push EOS when we can't start playback for some reason.
also avoid a crash when fed an empty file. Fixes #480543.

ChangeLog
ext/spc/gstspc.c

index 3303200..8355944 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-25  Wim Taymans  <wim.taymans@collabora.co.uk>
+
+       Patch by: Jonathan Matthew <notverysmart at gmail dot com>
+
+       * ext/spc/gstspc.c: (gst_spc_dec_sink_event), (spc_setup):
+       Post an error and push EOS when we can't start playback for some reason.
+       also avoid a crash when fed an empty file. Fixes #480543.
+
 2008-11-25  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
 
        * tests/check/elements/speexresample.c: (test_pipeline):
index b8d7810..c8ece37 100644 (file)
@@ -195,20 +195,27 @@ gst_spc_dec_sink_event (GstPad * pad, GstEvent * event)
 {
   GstSpcDec *spc = GST_SPC_DEC (gst_pad_get_parent (pad));
   gboolean result = TRUE;
+  gboolean forward = FALSE;
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_EOS:
-      result = spc_setup (spc);
-      break;
-    case GST_EVENT_NEWSEGMENT:
-      result = FALSE;
+      /* we get EOS when we loaded the complete file, now try to initialize the
+       * decoding */
+      if (!(result = spc_setup (spc))) {
+        /* can't start, post an ERROR and push EOS downstream */
+        GST_ELEMENT_ERROR (spc, STREAM, DEMUX, (NULL),
+            ("can't start playback"));
+        forward = TRUE;
+      }
       break;
     default:
-      result = FALSE;
       break;
   }
+  if (forward)
+    result = gst_pad_push_event (spc->srcpad, event);
+  else
+    gst_event_unref (event);
 
-  gst_event_unref (event);
   gst_object_unref (spc);
 
   return result;
@@ -453,18 +460,18 @@ spc_play (GstPad * pad)
 static gboolean
 spc_setup (GstSpcDec * spc)
 {
-  guchar *data = GST_BUFFER_DATA (spc->buf);
   spc_tag_info *info;
   GstTagList *taglist;
   guint64 total_duration;
 
-  if (!spc_negotiate (spc)) {
+  if (!spc->buf || !spc_negotiate (spc)) {
     return FALSE;
   }
 
   info = &(spc->tag_info);
 
-  spc_tag_get_info (data, GST_BUFFER_SIZE (spc->buf), info);
+  spc_tag_get_info (GST_BUFFER_DATA (spc->buf), GST_BUFFER_SIZE (spc->buf),
+      info);
 
   taglist = gst_tag_list_new ();