gst/gsttypefindfactory.c: Don't unref factories after calling them.
authorMichael Smith <msmith@xiph.org>
Mon, 12 Dec 2005 19:09:49 +0000 (19:09 +0000)
committerMichael Smith <msmith@xiph.org>
Mon, 12 Dec 2005 19:09:49 +0000 (19:09 +0000)
Original commit message from CVS:
* gst/gsttypefindfactory.c: (gst_type_find_factory_call_function):
Don't unref factories after calling them.
* libs/gst/base/gsttypefindhelper.c: (gst_type_find_helper):
* plugins/elements/gsttypefindelement.c:
(gst_type_find_element_chain):
Free lists of factories after using them. Fixing typefinding memory
leaks.

ChangeLog
gst/gsttypefindfactory.c
libs/gst/base/gsttypefindhelper.c
plugins/elements/gsttypefindelement.c

index 9673f94..1d19114 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-12-12  Michael Smith  <msmith@fluendo.com>
+
+       * gst/gsttypefindfactory.c: (gst_type_find_factory_call_function):
+         Don't unref factories after calling them.
+       * libs/gst/base/gsttypefindhelper.c: (gst_type_find_helper):
+       * plugins/elements/gsttypefindelement.c:
+       (gst_type_find_element_chain):
+         Free lists of factories after using them. Fixing typefinding memory
+         leaks.
+
 2005-12-12  Stefan Kost  <ensonic@users.sf.net>
 
        * gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
index 481afe0..47850fd 100644 (file)
@@ -239,6 +239,5 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory,
     g_assert (new_factory->function != NULL);
 
     new_factory->function (find, new_factory->user_data);
-    gst_object_unref (new_factory);
   }
 }
index 6656c06..b802a74 100644 (file)
@@ -170,6 +170,7 @@ gst_type_find_helper (GstPad * src, guint64 size)
       break;
     walk = g_list_next (walk);
   }
+  gst_plugin_feature_list_free (type_list);
 
   if (find.best_probability > 0)
     result = find.caps;
index 333880e..8f66813 100644 (file)
@@ -641,7 +641,6 @@ static GstFlowReturn
 gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstTypeFindElement *typefind;
-  GList *entries;
   TypeFindEntry *entry;
   GList *walk;
   GstFlowReturn res = GST_FLOW_OK;
@@ -687,26 +686,31 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
       }
 
       /* call every typefind function once */
-      walk = entries = typefind->possibilities;
+      walk = typefind->possibilities;
       GST_INFO_OBJECT (typefind, "iterating %u typefinding functions",
-          g_list_length (entries));
-      typefind->possibilities = NULL;
+          g_list_length (walk));
       while (walk) {
         find.data = entry = (TypeFindEntry *) walk->data;
-        walk = g_list_next (walk);
-        if (entry->probability == 0) {
-          entry->requested_size = 0;
-          gst_type_find_factory_call_function (entry->factory, &find);
-        } else {
-          typefind->possibilities =
-              g_list_prepend (typefind->possibilities, entry);
+        if (entry->probability != 0) {
+          /* Probability already known, just continue along the list */
+          walk = g_list_next (walk);
           continue;
         }
+
+        entry->requested_size = 0;
+        gst_type_find_factory_call_function (entry->factory, &find);
+
         if (entry->probability == 0 && entry->requested_size == 0) {
+          GList *next;
+
           GST_DEBUG_OBJECT (typefind,
               "'%s' was removed - no chance of being the right plugin",
               GST_PLUGIN_FEATURE_NAME (entry->factory));
+          next = g_list_next (walk);
           free_entry (entry);
+          typefind->possibilities =
+              g_list_delete_link (typefind->possibilities, walk);
+          walk = next;
         } else if (entry->probability >= typefind->max_probability) {
           /* wooha, got caps */
           GstCaps *found_caps = entry->caps;
@@ -716,28 +720,19 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
               "'%s' returned %u/%u probability, using it NOW",
               GST_PLUGIN_FEATURE_NAME (entry->factory), probability,
               typefind->max_probability);
-          while (walk) {
-            free_entry ((TypeFindEntry *) walk->data);
-            walk = g_list_next (walk);
-          }
-          walk = typefind->possibilities;
-          while (walk) {
-            free_entry (walk->data);
-            walk = g_list_next (walk);
-          }
-          g_list_free (typefind->possibilities);
-          typefind->possibilities = NULL;
           g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
               probability, found_caps);
-          free_entry (entry);
+
+          g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
+          g_list_free (typefind->possibilities);
+          typefind->possibilities = NULL;
+          break;
         } else {
-          typefind->possibilities =
-              g_list_prepend (typefind->possibilities, entry);
+          walk = g_list_next (walk);
           if (entry->requested_size != 0)
             done = FALSE;
         }
       }
-      g_list_free (entries);
 
       /* we may now already have caps or we might be left without functions to try */
       if (typefind->caps) {