gst/gstpad.override: Wrap gst.Pad.start_task().
authorEdward Hervey <bilboed@bilboed.com>
Sun, 10 Feb 2008 13:30:11 +0000 (13:30 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Sun, 10 Feb 2008 13:30:11 +0000 (13:30 +0000)
Original commit message from CVS:
* gst/gstpad.override:
Wrap gst.Pad.start_task().

ChangeLog
common
gst/gstpad.override

index 9ffa816..b53e429 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-10  Edward Hervey  <edward.hervey@collabora.co.uk>
+
+       * gst/gstpad.override:
+       Wrap gst.Pad.start_task().
+
 2008-02-08  Edward Hervey  <edward.hervey@collabora.co.uk>
 
        * gst/base.defs:
diff --git a/common b/common
index 8b37d7e..961bb6b 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 8b37d7ee833fab1d25b484d8574df3dae231b5f2
+Subproject commit 961bb6bd997d7c8da6058534e86b4a1361c0fcea
index 70f76de..8b32124 100644 (file)
@@ -1525,4 +1525,85 @@ _wrap_gst_static_pad_template__get_static_caps(PyObject *self, void *closure)
     templ = pyg_pointer_get(self, GstStaticPadTemplate);
     return pyg_pointer_new(GST_TYPE_STATIC_CAPS, &(templ->static_caps));
 }
+%%
+override gst_pad_start_task args
+static void
+pad_task_handler(void *data) {
+    PyGILState_STATE state;
+    PyObject *callback, *args = NULL;
+    PyObject *py_user_data;
+
+    if (data == NULL)
+       return;
+
+    state = pyg_gil_state_ensure();
+    py_user_data = (PyObject*) data;
+
+    callback = PyTuple_GetItem(py_user_data, 0);
+    if (!(PyCallable_Check(callback))) {
+       PyErr_Print();
+       goto beach;
+    }
+    if (!(args = PyTuple_GetSlice(py_user_data, 1, PyTuple_Size(py_user_data)))) {
+       PyErr_Print();
+       goto beach;
+    }
+
+    if (!(PyTuple_Check(args))) {
+       PyErr_Print();
+       goto beach;
+    }
+
+    PyObject_CallObject(callback, args);
+
+    if(PyErr_Occurred())
+       PyErr_Print();
+
+    Py_DECREF(args);
+
+ beach:
+    pyg_gil_state_release(state);
+}
+
+static PyObject *
+_wrap_gst_pad_start_task(PyGObject *self, PyObject *args)
+{
+    PyObject *callback, *data, *cbargs, *py_ret;
+    gboolean ret;
+
+    /* 1st argument must be a callable */
+    if (PyTuple_Size(args) < 1) {
+       PyErr_SetString(PyExc_TypeError, "gst.Pad.start_task() requires at least 1 argument");
+       return NULL;
+    }
+
+    callback = PySequence_GetItem(args, 0);
+    if (!PyCallable_Check(callback)) {
+       PyErr_SetString(PyExc_TypeError, "callback must be a function or method");
+       Py_DECREF(callback);
+       return NULL;
+    }
+    
+    if (!(cbargs = PySequence_GetSlice(args, 1, PyTuple_Size(args)))) {
+       Py_DECREF(callback);
+       return NULL;
+    }
 
+    if (!(data = Py_BuildValue("(ON)", callback, cbargs))) {
+       Py_DECREF(callback);
+       Py_DECREF(cbargs);
+       return NULL;
+    }
+    
+    pyg_begin_allow_threads;
+    ret = gst_pad_start_task(GST_PAD(self->obj), (GstTaskFunction) pad_task_handler, data);
+    pyg_end_allow_threads;
+
+    if (ret == TRUE)
+       py_ret = Py_True;
+    else
+       py_ret = Py_False;
+
+    Py_INCREF(py_ret);
+    return py_ret;
+}