Return GST_FLOW_NOT_NEGOTIATED if we get a buffer without caps, and add a somewhat...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 7 Feb 2008 21:17:36 +0000 (21:17 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 7 Feb 2008 21:17:36 +0000 (21:17 +0000)
Original commit message from CVS:
* gst/icydemux/gsticydemux.c: (gst_icydemux_chain):
* tests/check/elements/icydemux.c:
Return GST_FLOW_NOT_NEGOTIATED if we get a buffer without
caps, and add a somewhat useful debug message. Plus test.

ChangeLog
gst/icydemux/gsticydemux.c
tests/check/elements/icydemux.c

index 3d2b07f..ebcba0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-07  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/icydemux/gsticydemux.c: (gst_icydemux_chain):
+       * tests/check/elements/icydemux.c:
+         Return GST_FLOW_NOT_NEGOTIATED if we get a buffer without
+         caps, and add a somewhat useful debug message. Plus test.
+
 2008-02-07  Sebastien Moutte  <sebastien@moutte.net>
 
        * gst/rtsp/gstrtspsrc.c:
index d99b29f..3dc47d4 100644 (file)
@@ -497,8 +497,9 @@ gst_icydemux_chain (GstPad * pad, GstBuffer * buf)
   GstFlowReturn ret = GST_FLOW_OK;
 
   icydemux = GST_ICYDEMUX (GST_PAD_PARENT (pad));
-  g_return_val_if_fail (GST_IS_ICYDEMUX (icydemux), GST_FLOW_ERROR);
-  g_return_val_if_fail (icydemux->meta_interval >= 0, GST_FLOW_ERROR);
+
+  if (G_UNLIKELY (icydemux->meta_interval < 0))
+    goto not_negotiated;
 
   if (icydemux->meta_interval == 0) {
     ret = gst_icydemux_typefind_or_forward (icydemux, buf);
@@ -558,6 +559,15 @@ done:
   gst_buffer_unref (buf);
 
   return ret;
+
+/* ERRORS */
+not_negotiated:
+  {
+    GST_WARNING_OBJECT (icydemux, "meta_interval not set, buffer probably had "
+        "no caps set. Try enabling iradio-mode on the http source element");
+    gst_buffer_unref (buf);
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
 }
 
 static GstStateChangeReturn
index 480210f..12b14fb 100644 (file)
@@ -117,7 +117,8 @@ cleanup_icydemux (void)
   bus = NULL;
 
   gst_check_teardown_src_pad (icydemux);
-  gst_check_teardown_sink_pad (icydemux);
+  if (sinkpad)
+    gst_check_teardown_sink_pad (icydemux);
   gst_check_teardown_element (icydemux);
 
   srcpad = NULL;
@@ -229,6 +230,23 @@ GST_START_TEST (test_first_buf_offset_when_merged_for_typefinding)
 
 GST_END_TEST;
 
+GST_START_TEST (test_not_negotiated)
+{
+  GstBuffer *buf;
+
+  create_icydemux ();
+
+  buf = gst_buffer_new_and_alloc (0);
+  GST_BUFFER_OFFSET (buf) = 0;
+
+  fail_unless_equals_int (gst_pad_push (srcpad, buf), GST_FLOW_NOT_NEGOTIATED);
+  buf = NULL;
+
+  cleanup_icydemux ();
+}
+
+GST_END_TEST;
+
 static Suite *
 icydemux_suite (void)
 {
@@ -238,6 +256,7 @@ icydemux_suite (void)
   suite_add_tcase (s, tc_chain);
   tcase_add_test (tc_chain, test_demux);
   tcase_add_test (tc_chain, test_first_buf_offset_when_merged_for_typefinding);
+  tcase_add_test (tc_chain, test_not_negotiated);
 
   return s;
 }