mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
gst/gstpad.override: (pad_block_callback_marshal)
Original commit message from CVS: 2006-04-19 Andy Wingo <wingo@pobox.com> * gst/gstpad.override: (pad_block_callback_marshal) (_wrap_gst_pad_set_blocked_async): Fix refcounting problems and indent. Fixes #338982
This commit is contained in:
parent
726357893f
commit
a0da01acaa
1 changed files with 22 additions and 30 deletions
|
@ -963,9 +963,7 @@ pad_block_callback_marshal(GstPad *pad, gboolean blocked, gpointer user_data)
|
||||||
PyGILState_STATE state;
|
PyGILState_STATE state;
|
||||||
PyObject *callback, *args;
|
PyObject *callback, *args;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
PyObject *py_data;
|
|
||||||
PyObject *py_user_data;
|
PyObject *py_user_data;
|
||||||
gint len, i;
|
|
||||||
|
|
||||||
g_return_if_fail(user_data != NULL);
|
g_return_if_fail(user_data != NULL);
|
||||||
|
|
||||||
|
@ -973,32 +971,26 @@ pad_block_callback_marshal(GstPad *pad, gboolean blocked, gpointer user_data)
|
||||||
|
|
||||||
py_user_data = (PyObject *) user_data;
|
py_user_data = (PyObject *) user_data;
|
||||||
|
|
||||||
if (blocked)
|
|
||||||
py_data = Py_True;
|
|
||||||
else
|
|
||||||
py_data = Py_False;
|
|
||||||
Py_INCREF(py_data);
|
|
||||||
|
|
||||||
callback = PyTuple_GetItem(py_user_data, 0);
|
callback = PyTuple_GetItem(py_user_data, 0);
|
||||||
args = Py_BuildValue("(NN)",
|
args = Py_BuildValue("(NO)",
|
||||||
pygstobject_new(G_OBJECT(pad)),
|
pygstobject_new(G_OBJECT(pad)),
|
||||||
py_data);
|
blocked ? Py_True : Py_False);
|
||||||
|
|
||||||
len = PyTuple_Size(py_user_data);
|
{
|
||||||
for (i = 1; i < len; ++i) {
|
PyObject *tmp = args;
|
||||||
PyObject *tuple = args;
|
args = PySequence_Concat(tmp, PyTuple_GetItem(py_user_data, 1));
|
||||||
args = PySequence_Concat(tuple, PyTuple_GetItem(py_user_data, i));
|
Py_DECREF (tmp);
|
||||||
Py_DECREF(tuple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = PyObject_CallObject(callback, args);
|
ret = PyObject_CallObject(callback, args);
|
||||||
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
else
|
||||||
|
Py_DECREF(ret);
|
||||||
|
|
||||||
Py_DECREF(py_data);
|
|
||||||
Py_DECREF(args);
|
|
||||||
pyg_gil_state_release(state);
|
pyg_gil_state_release(state);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1013,29 +1005,29 @@ _wrap_gst_pad_set_blocked_async (PyGObject *self, PyObject *args)
|
||||||
len = PyTuple_Size(args);
|
len = PyTuple_Size(args);
|
||||||
|
|
||||||
if (len < 2) {
|
if (len < 2) {
|
||||||
PyErr_SetString(PyExc_TypeError, "Requires at least 2 arg");
|
PyErr_SetString(PyExc_TypeError, "Requires at least 2 arg");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pblocked = PySequence_GetItem(args, 0);
|
pblocked = PyTuple_GetItem(args, 0);
|
||||||
blocked = PyObject_IsTrue(pblocked);
|
blocked = PyObject_IsTrue(pblocked);
|
||||||
|
|
||||||
callback = PySequence_GetItem(args, 1);
|
callback = PyTuple_GetItem(args, 1);
|
||||||
if (!PyCallable_Check(callback)) {
|
if (!PyCallable_Check(callback)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cbargs = PySequence_GetSlice(args, 2, len);
|
cbargs = PySequence_GetSlice(args, 2, len);
|
||||||
if (cbargs == NULL)
|
if (cbargs == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
data = Py_BuildValue("(ON)", callback, cbargs);
|
data = Py_BuildValue("(ON)", callback, cbargs);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = gst_pad_set_blocked_async (GST_PAD (self->obj), blocked,
|
ret = gst_pad_set_blocked_async (GST_PAD (self->obj), blocked,
|
||||||
(GstPadBlockCallback) pad_block_callback_marshal, data);
|
(GstPadBlockCallback) pad_block_callback_marshal, data);
|
||||||
if (ret)
|
if (ret)
|
||||||
pret = Py_True;
|
pret = Py_True;
|
||||||
else
|
else
|
||||||
pret = Py_False;
|
pret = Py_False;
|
||||||
Py_INCREF(pret);
|
Py_INCREF(pret);
|
||||||
|
|
||||||
return pret;
|
return pret;
|
||||||
|
|
Loading…
Reference in a new issue