[farsight2/master] test: Test if it caues a problem if the session/stream is destroyed while the stuff is running

Olivier Crête olivier.crete at collabora.co.uk
Tue Jul 14 13:15:48 PDT 2009


---
 tests/check/rtp/conference.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 tests/check/rtp/generic.c    |    6 ++++--
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/tests/check/rtp/conference.c b/tests/check/rtp/conference.c
index 065f78a..fb2a428 100644
--- a/tests/check/rtp/conference.c
+++ b/tests/check/rtp/conference.c
@@ -362,6 +362,9 @@ _handoff_handler (GstElement *element, GstBuffer *buffer, GstPad *pad,
   gboolean stop = TRUE;
   GList *codecs = NULL;
 
+  if (st->dat->session == NULL)
+    return;
+
   g_object_get (st->dat->session,
       "codecs", &codecs,
       NULL);
@@ -1352,6 +1355,41 @@ min_timeout (TCase *tc_chain, guint min)
   tcase_set_timeout (tc_chain, MAX (min, tmp));
 }
 
+static void unref_session_on_src_pad_added (FsStream *stream,
+    GstPad *pad, FsCodec *codec, struct SimpleTestStream *st)
+{
+  g_object_unref (st->dat->session);
+  st->dat->session = NULL;
+  g_object_unref (st->stream);
+  st->stream = NULL;
+
+  g_main_loop_quit (loop);
+}
+
+static void unref_session_init (void)
+{
+  gint i;
+
+  for (i=0 ; i < 2; i++)
+  {
+    GList *item;
+
+    for (item = dats[i]->streams; item; item = item->next)
+    {
+      struct SimpleTestStream *st = item->data;
+
+      g_signal_connect (st->stream, "src-pad-added",
+          G_CALLBACK (unref_session_on_src_pad_added), st);
+    }
+  }
+}
+
+GST_START_TEST (test_rtpconference_unref_session_in_pad_added)
+{
+  nway_test (2, unref_session_init, "rawudp", 0, NULL);
+}
+GST_END_TEST;
+
 static Suite *
 fsrtpconference_suite (void)
 {
@@ -1432,6 +1470,10 @@ fsrtpconference_suite (void)
   tcase_add_test (tc_chain, test_rtpconference_multicast_three_way_ssrc_assoc);
   suite_add_tcase (s, tc_chain);
 
+  tc_chain = tcase_create ("fsrtpconference_unref_session_in_pad_added");
+  tcase_add_test (tc_chain, test_rtpconference_unref_session_in_pad_added);
+  suite_add_tcase (s, tc_chain);
+
   return s;
 }
 
diff --git a/tests/check/rtp/generic.c b/tests/check/rtp/generic.c
index 4009a06..712ec70 100644
--- a/tests/check/rtp/generic.c
+++ b/tests/check/rtp/generic.c
@@ -102,7 +102,8 @@ simple_conference_add_stream (
 void
 cleanup_simple_stream (struct SimpleTestStream *st)
 {
-  g_object_unref (st->stream);
+  if (st->stream)
+    g_object_unref (st->stream);
   g_object_unref (st->participant);
   g_free (st);
 }
@@ -114,7 +115,8 @@ cleanup_simple_conference (struct SimpleTestConference *dat)
   g_list_foreach (dat->streams, (GFunc) cleanup_simple_stream, NULL);
   g_list_free (dat->streams);
 
-  g_object_unref (dat->session);
+  if (dat->session)
+    g_object_unref (dat->session);
   gst_object_unref (dat->pipeline);
   g_free (dat->cname);
   g_free (dat);
-- 
1.5.6.5



More information about the farsight-commits mailing list