Make fakesink removal work even when there's no demuxer to emit a no-more-pads signal
authorMikko Rasa <mikko.rasa@movial.fi>
Wed, 10 Jun 2009 07:28:36 +0000 (10:28 +0300)
committerMikko Rasa <mikko.rasa@movial.fi>
Wed, 10 Jun 2009 07:28:36 +0000 (10:28 +0300)
src/octopus-backend-gst.c
src/octopus-backend-gst.h

index 1dd7ea0..caa5d43 100644 (file)
@@ -531,6 +531,20 @@ seek_route(OctopusBackend *backend,
  */
 
 static void
+remove_fakesink(OctopusRoute *route)
+{
+  RouteDataGst *data;
+
+  data = (RouteDataGst *)g_object_get_data(G_OBJECT(route), "data");
+
+  if(data->fakesink) {
+    gst_element_set_state(data->fakesink, GST_STATE_NULL);
+    gst_bin_remove(GST_BIN(data->pipeline), data->fakesink);
+    data->fakesink = NULL;
+  }
+}
+
+static void
 configure_endpoint(GstElement            *elem,
                    const OctopusEndpoint *endpoint)
 {
@@ -618,6 +632,11 @@ realize_element(OctopusRoute   *route,
     if(GST_PAD_TEMPLATE_DIRECTION(tmpl) == GST_PAD_SRC
        && GST_PAD_TEMPLATE_PRESENCE(tmpl) == GST_PAD_SOMETIMES)
     {
+      RouteDataGst *data;
+
+      data = (RouteDataGst *)g_object_get_data(G_OBJECT(route), "data");
+      data->have_dynpads = TRUE;
+
       g_debug("Connecting to dynamic pad signals");
       g_signal_connect(G_OBJECT(gst_elem), "pad-added", G_CALLBACK(pad_added), route);
       g_signal_connect(G_OBJECT(gst_elem), "pad-removed", G_CALLBACK(pad_removed), route);
@@ -670,6 +689,9 @@ realize_component(OctopusBackend   *backend,
     srcpad = gst_element_get_static_pad(gst_elem, "src");
   }
 
+  if(!srcpad && !data->have_dynpads)
+    remove_fakesink(route);
+
   return srcpad;
 }
 
@@ -998,11 +1020,7 @@ no_more_pads(GstElement *elem,
 
   data->ready = TRUE;
 
-  if(data->fakesink) {
-    gst_element_set_state(data->fakesink, GST_STATE_NULL);
-    gst_bin_remove(GST_BIN(data->pipeline), data->fakesink);
-    data->fakesink = NULL;
-  }
+  remove_fakesink(route);
 }
 
 static void
index 0dfec44..43ebf9c 100644 (file)
@@ -57,6 +57,7 @@ struct _OctopusRouteDataGst
   GstElement *pipeline;
   GstElement *fakesink;
   gboolean   have_type;
+  gboolean   have_dynpads;
   gboolean   ready;
   guint      timeout_tag;
   GSList     *modules;