diff --git a/ChangeLog b/ChangeLog index 3d2b07f1cf..ebcba0f9c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-07 Tim-Philipp Müller + + * 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 * gst/rtsp/gstrtspsrc.c: diff --git a/gst/icydemux/gsticydemux.c b/gst/icydemux/gsticydemux.c index d99b29f987..3dc47d42aa 100644 --- a/gst/icydemux/gsticydemux.c +++ b/gst/icydemux/gsticydemux.c @@ -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 diff --git a/tests/check/elements/icydemux.c b/tests/check/elements/icydemux.c index 480210fa0f..12b14fb6c8 100644 --- a/tests/check/elements/icydemux.c +++ b/tests/check/elements/icydemux.c @@ -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; }