typefind: fix caps leak when used in connection with uridecodebin and playbin
authorTim-Philipp Müller <tim@centricular.net>
Fri, 26 Apr 2013 23:05:45 +0000 (00:05 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 26 Apr 2013 23:05:45 +0000 (00:05 +0100)
Don't leak forced sink caps.

plugins/elements/gsttypefindelement.c
tests/check/pipelines/simple-launch-lines.c

index a94439e..f333fb4 100644 (file)
@@ -1195,6 +1195,7 @@ gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent)
     GST_DEBUG ("Emiting found caps %" GST_PTR_FORMAT, found_caps);
     g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
         0, probability, found_caps);
+    gst_caps_unref (found_caps);
     typefind->mode = MODE_NORMAL;
     /* the signal above could have made a downstream element activate
      * the pad in pull mode, we check if the pad is already active now and if
index 1429500..62385b2 100644 (file)
@@ -310,6 +310,20 @@ GST_START_TEST (test_stop_from_app)
 
 GST_END_TEST;
 
+GST_START_TEST (test_typefind_force_sink_caps)
+{
+  const gchar *s;
+
+  s = "fakesrc can-activate-push=true num-buffers=5 ! "
+      "typefind force-caps=foo/x-bar ! fakesink can-activate-push=true";
+  ASSERT_CRITICAL (run_pipeline (setup_pipeline (s), s,
+          GST_MESSAGE_NEW_CLOCK | GST_MESSAGE_STATE_CHANGED |
+          GST_MESSAGE_STREAM_STATUS | GST_MESSAGE_ASYNC_DONE |
+          GST_MESSAGE_STREAM_START, GST_MESSAGE_UNKNOWN));
+}
+
+GST_END_TEST;
+
 static Suite *
 simple_launch_lines_suite (void)
 {
@@ -324,6 +338,8 @@ simple_launch_lines_suite (void)
   tcase_add_test (tc_chain, test_state_change_returns);
   /* tcase_add_test (tc_chain, test_tee); FIXME */
   tcase_add_test (tc_chain, test_stop_from_app);
+  tcase_add_test (tc_chain, test_typefind_force_sink_caps);
+
   return s;
 }