- id add_iterate_bin(bin)
authorDavid I. Lehn <dlehn@users.sourceforge.net>
Wed, 5 Feb 2003 15:53:58 +0000 (15:53 +0000)
committerDavid I. Lehn <dlehn@users.sourceforge.net>
Wed, 5 Feb 2003 15:53:58 +0000 (15:53 +0000)
Original commit message from CVS:
add functions for optimized bin iteration (may move or rename):
- id add_iterate_bin(bin)
- remove_iterate_bin(id)
- iterate_bin_all(bin)

gst/gstreamer-extra.defs
gst/gstreamer-fixes.c
gst/gstreamer-fixes.h
gstreamer/gstreamer-extra.defs
gstreamer/gstreamer-fixes.c
gstreamer/gstreamer-fixes.h

index 205f4a5..45649f2 100644 (file)
 )
 
 ;;
+;; Accelerate common GstBin iterate loop
+;;
+
+(define-function iterate_bin_all
+  (c-name "iterate_bin_all")
+  (return-type "none")
+  (parameters
+    '("GstBin*" "bin")
+  )
+)
+
+(define-function add_iterate_bin
+  (c-name "add_iterate_bin")
+  (return-type "guint")
+  (parameters
+    '("GstBin*" "bin")
+  )
+)
+
+(define-function remove_iterate_bin
+  (c-name "remove_iterate_bin")
+  (return-type "none")
+  (parameters
+    '("guint" "id")
+  )
+)
+
+;;
 ;; HACK
 ;;
 
index 2b5252e..f3cfc62 100644 (file)
  * Author: David I. Lehn <dlehn@users.sourceforge.net>
  */
 
+#include "pygobject.h"
 #include <gst/gst.h>
 
 #include "gstreamer-fixes.h"
+
+void iterate_bin_all(GstBin *bin) {
+       g_return_if_fail(bin != NULL);
+       g_return_if_fail(GST_IS_BIN(bin));
+
+       pyg_unblock_threads();
+       while (gst_bin_iterate(bin));
+       pyg_block_threads();
+}
+
+static gboolean iterate_bin(gpointer data) {
+       GstBin *bin;
+
+       bin = GST_BIN(data);
+       return gst_bin_iterate(bin);
+}
+
+static void iterate_bin_destroy(gpointer data) {
+       GstBin *bin;
+
+       bin = GST_BIN(data);
+       gst_object_unref(GST_OBJECT(bin));
+}
+
+guint add_iterate_bin(GstBin *bin) {
+       g_return_val_if_fail(bin != NULL, FALSE);
+       g_return_val_if_fail(GST_IS_BIN(bin), FALSE);
+
+       gst_object_ref(GST_OBJECT(bin));
+       return g_idle_add_full(
+                       G_PRIORITY_DEFAULT_IDLE,
+                       iterate_bin,
+                       bin,
+                       iterate_bin_destroy);
+}
+
+void remove_iterate_bin(guint id) {
+       g_source_remove(id);
+}
index 04d6fb1..a63f174 100644 (file)
@@ -25,6 +25,6 @@
 #include <gst/gstqueue.h>
 #include <gst/gsttypefind.h>
 
-/* 0.4.1 headers had typo: s/gst/get/ */
-#define GST_TYPE_CAPS (_gst_caps_type)
-#define GST_TYPE_PROPS (_gst_props_type)
+void iterate_bin_all(GstBin *bin);
+guint add_iterate_bin(GstBin *bin);
+void remove_iterate_bin(guint id);
index 205f4a5..45649f2 100644 (file)
 )
 
 ;;
+;; Accelerate common GstBin iterate loop
+;;
+
+(define-function iterate_bin_all
+  (c-name "iterate_bin_all")
+  (return-type "none")
+  (parameters
+    '("GstBin*" "bin")
+  )
+)
+
+(define-function add_iterate_bin
+  (c-name "add_iterate_bin")
+  (return-type "guint")
+  (parameters
+    '("GstBin*" "bin")
+  )
+)
+
+(define-function remove_iterate_bin
+  (c-name "remove_iterate_bin")
+  (return-type "none")
+  (parameters
+    '("guint" "id")
+  )
+)
+
+;;
 ;; HACK
 ;;
 
index 2b5252e..f3cfc62 100644 (file)
  * Author: David I. Lehn <dlehn@users.sourceforge.net>
  */
 
+#include "pygobject.h"
 #include <gst/gst.h>
 
 #include "gstreamer-fixes.h"
+
+void iterate_bin_all(GstBin *bin) {
+       g_return_if_fail(bin != NULL);
+       g_return_if_fail(GST_IS_BIN(bin));
+
+       pyg_unblock_threads();
+       while (gst_bin_iterate(bin));
+       pyg_block_threads();
+}
+
+static gboolean iterate_bin(gpointer data) {
+       GstBin *bin;
+
+       bin = GST_BIN(data);
+       return gst_bin_iterate(bin);
+}
+
+static void iterate_bin_destroy(gpointer data) {
+       GstBin *bin;
+
+       bin = GST_BIN(data);
+       gst_object_unref(GST_OBJECT(bin));
+}
+
+guint add_iterate_bin(GstBin *bin) {
+       g_return_val_if_fail(bin != NULL, FALSE);
+       g_return_val_if_fail(GST_IS_BIN(bin), FALSE);
+
+       gst_object_ref(GST_OBJECT(bin));
+       return g_idle_add_full(
+                       G_PRIORITY_DEFAULT_IDLE,
+                       iterate_bin,
+                       bin,
+                       iterate_bin_destroy);
+}
+
+void remove_iterate_bin(guint id) {
+       g_source_remove(id);
+}
index 04d6fb1..a63f174 100644 (file)
@@ -25,6 +25,6 @@
 #include <gst/gstqueue.h>
 #include <gst/gsttypefind.h>
 
-/* 0.4.1 headers had typo: s/gst/get/ */
-#define GST_TYPE_CAPS (_gst_caps_type)
-#define GST_TYPE_PROPS (_gst_props_type)
+void iterate_bin_all(GstBin *bin);
+guint add_iterate_bin(GstBin *bin);
+void remove_iterate_bin(guint id);