summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid I. Lehn <dlehn@users.sourceforge.net>2003-02-05 15:53:58 +0000
committerDavid I. Lehn <dlehn@users.sourceforge.net>2003-02-05 15:53:58 +0000
commit5b2442792a60a9505a09141498a42078e9f96ff7 (patch)
treeabbf4bbc0529f6a647137d0339927dec24f74bbf
parent9a3256eeb15719aaa93490bd6b087426d0f38a96 (diff)
- id add_iterate_bin(bin)
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)
-rw-r--r--gst/gstreamer-extra.defs28
-rw-r--r--gst/gstreamer-fixes.c40
-rw-r--r--gst/gstreamer-fixes.h6
-rw-r--r--gstreamer/gstreamer-extra.defs28
-rw-r--r--gstreamer/gstreamer-fixes.c40
-rw-r--r--gstreamer/gstreamer-fixes.h6
6 files changed, 142 insertions, 6 deletions
diff --git a/gst/gstreamer-extra.defs b/gst/gstreamer-extra.defs
index 205f4a5..45649f2 100644
--- a/gst/gstreamer-extra.defs
+++ b/gst/gstreamer-extra.defs
@@ -39,6 +39,34 @@
)
;;
+;; 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
;;
diff --git a/gst/gstreamer-fixes.c b/gst/gstreamer-fixes.c
index 2b5252e..f3cfc62 100644
--- a/gst/gstreamer-fixes.c
+++ b/gst/gstreamer-fixes.c
@@ -19,6 +19,46 @@
* 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);
+}
diff --git a/gst/gstreamer-fixes.h b/gst/gstreamer-fixes.h
index 04d6fb1..a63f174 100644
--- a/gst/gstreamer-fixes.h
+++ b/gst/gstreamer-fixes.h
@@ -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);
diff --git a/gstreamer/gstreamer-extra.defs b/gstreamer/gstreamer-extra.defs
index 205f4a5..45649f2 100644
--- a/gstreamer/gstreamer-extra.defs
+++ b/gstreamer/gstreamer-extra.defs
@@ -39,6 +39,34 @@
)
;;
+;; 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
;;
diff --git a/gstreamer/gstreamer-fixes.c b/gstreamer/gstreamer-fixes.c
index 2b5252e..f3cfc62 100644
--- a/gstreamer/gstreamer-fixes.c
+++ b/gstreamer/gstreamer-fixes.c
@@ -19,6 +19,46 @@
* 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);
+}
diff --git a/gstreamer/gstreamer-fixes.h b/gstreamer/gstreamer-fixes.h
index 04d6fb1..a63f174 100644
--- a/gstreamer/gstreamer-fixes.h
+++ b/gstreamer/gstreamer-fixes.h
@@ -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);