gst: Don't use private GstPad API to add data/buffer/event probes

This does not work anymore with latest core because of the
pad cache that enables use of a fast path during data passing
in many situations.

Fixes bug #650987.
This commit is contained in:
Sebastian Dröge 2011-05-25 09:38:22 +02:00
parent d4eb9e9bf9
commit fe9d91f321

View file

@ -859,175 +859,175 @@ _wrap_gst_pad_new(PyGObject *self, PyObject *args, PyObject *kwargs)
} }
%% %%
override gst_pad_add_data_probe args override gst_pad_add_data_probe args
static void
data_probe_destroy_data (gpointer data)
{
PyGILState_STATE state;
PyObject *py_data = (PyObject *) data;
state = pyg_gil_state_ensure();
Py_DECREF (py_data);
pyg_gil_state_release(state);
}
static gboolean
data_probe_callback_marshal(GstPad *pad, GstMiniObject *obj, gpointer user_data)
{
PyGILState_STATE state;
PyObject *callback, *args;
PyObject *pret;
PyObject *py_user_data;
gboolean ret;
g_return_val_if_fail(user_data != NULL, TRUE);
state = pyg_gil_state_ensure();
py_user_data = (PyObject *) user_data;
callback = PyTuple_GetItem(py_user_data, 0);
args = Py_BuildValue("(NN)",
pygobject_new(G_OBJECT(pad)),
pygstminiobject_new(GST_MINI_OBJECT(obj)));
{
PyObject *tmp = args;
args = PySequence_Concat(tmp, PyTuple_GetItem(py_user_data, 1));
Py_DECREF (tmp);
}
pret = PyObject_CallObject(callback, args);
Py_DECREF(args);
if (!pret) {
PyErr_Print();
ret = TRUE;
} else {
ret = PyObject_IsTrue(pret)? TRUE : FALSE;
Py_DECREF(pret);
}
pyg_gil_state_release(state);
}
static PyObject * static PyObject *
_wrap_gst_pad_add_data_probe(PyGObject *self, PyObject *args) _wrap_gst_pad_add_data_probe(PyGObject *self, PyObject *args)
{ {
GstPad *pad = GST_PAD(self->obj); PyObject *callback, *cbargs = NULL, *data;
PyObject *method = NULL; PyObject *pret;
PyObject *rv = NULL; gulong ret;
PyObject *mylist = PyList_New(1); gint len;
PyObject *mynewlist = NULL;
PyObject *myargs = NULL;
PyObject *signalname = NULL;
signalname = PyString_FromString("have-data"); len = PyTuple_Size(args);
if (len < 1) {
if (PyList_SetItem(mylist, 0, signalname)) { PyErr_SetString(PyExc_TypeError, "Requires at least 1 arg");
Py_DECREF(mylist);
return NULL;
}
mynewlist = PySequence_InPlaceConcat(mylist, args);
Py_DECREF(mylist);
if (!mynewlist)
return NULL;
myargs = PyList_AsTuple(mynewlist);
Py_DECREF(mynewlist);
if (!myargs)
return NULL;
method = PyObject_GetAttrString((PyObject*)self, "connect");
if (!method) {
Py_DECREF(mylist);
return NULL; return NULL;
} }
GST_OBJECT_LOCK (pad); callback = PyTuple_GetItem(args, 0);
if (!PyCallable_Check(callback)) {
rv = PyObject_CallObject(method, myargs); PyErr_SetString(PyExc_TypeError, "callback is not callable");
if (rv) { return NULL;
GST_PAD_DO_BUFFER_SIGNALS (pad)++;
GST_PAD_DO_EVENT_SIGNALS (pad)++;
GST_DEBUG_OBJECT (pad, "adding data probe, now %d buffer probes "
"and %d event probes", GST_PAD_DO_BUFFER_SIGNALS (pad),
GST_PAD_DO_EVENT_SIGNALS (pad));
} }
cbargs = PySequence_GetSlice(args, 1, len);
if (cbargs == NULL)
return NULL;
data = Py_BuildValue("(ON)", callback, cbargs);
if (data == NULL)
return NULL;
GST_OBJECT_UNLOCK (pad); pyg_begin_allow_threads;
ret = gst_pad_add_data_probe_full(GST_PAD(self->obj),
(GCallback) data_probe_callback_marshal, data,
data_probe_destroy_data);
pyg_end_allow_threads;
Py_DECREF(myargs); pret = PyLong_FromUnsignedLong(ret);
Py_DECREF(method); Py_INCREF(pret);
return rv; return pret;
} }
%% %%
override gst_pad_add_event_probe args override gst_pad_add_event_probe args
static PyObject * static PyObject *
_wrap_gst_pad_add_event_probe(PyGObject *self, PyObject *args) _wrap_gst_pad_add_event_probe(PyGObject *self, PyObject *args)
{ {
GstPad *pad = GST_PAD(self->obj); PyObject *callback, *cbargs = NULL, *data;
PyObject *method = NULL; PyObject *pret;
PyObject *rv = NULL; gulong ret;
PyObject *mylist = PyList_New(1); gint len;
PyObject *mynewlist = NULL;
PyObject *myargs = NULL;
PyObject *signalname = NULL;
signalname = PyString_FromString("have-data::event"); len = PyTuple_Size(args);
if (len < 1) {
if (PyList_SetItem(mylist, 0, signalname)) { PyErr_SetString(PyExc_TypeError, "Requires at least 1 arg");
Py_DECREF(mylist);
return NULL;
}
mynewlist = PySequence_InPlaceConcat(mylist, args);
Py_DECREF(mylist);
if (!mynewlist)
return NULL;
myargs = PyList_AsTuple(mynewlist);
Py_DECREF(mynewlist);
if (!myargs)
return NULL;
method = PyObject_GetAttrString((PyObject*)self, "connect");
if (!method) {
Py_DECREF(mylist);
return NULL; return NULL;
} }
GST_OBJECT_LOCK (pad); callback = PyTuple_GetItem(args, 0);
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "callback is not callable");
return NULL;
}
cbargs = PySequence_GetSlice(args, 1, len);
if (cbargs == NULL)
return NULL;
data = Py_BuildValue("(ON)", callback, cbargs);
if (data == NULL)
return NULL;
rv = PyObject_CallObject(method, myargs); pyg_begin_allow_threads;
if (rv) { ret = gst_pad_add_event_probe_full(GST_PAD(self->obj),
GST_PAD_DO_EVENT_SIGNALS (pad)++; (GCallback) data_probe_callback_marshal, data,
GST_DEBUG_OBJECT (pad, "adding event probe, now %d probes", data_probe_destroy_data);
GST_PAD_DO_EVENT_SIGNALS (pad)); pyg_end_allow_threads;
}
GST_OBJECT_UNLOCK (pad);
Py_DECREF(myargs); pret = PyLong_FromUnsignedLong(ret);
Py_DECREF(method); Py_INCREF(pret);
return rv; return pret;
} }
%% %%
override gst_pad_add_buffer_probe args override gst_pad_add_buffer_probe args
static PyObject * static PyObject *
_wrap_gst_pad_add_buffer_probe(PyGObject *self, PyObject *args) _wrap_gst_pad_add_buffer_probe(PyGObject *self, PyObject *args)
{ {
GstPad *pad = GST_PAD(self->obj); PyObject *callback, *cbargs = NULL, *data;
PyObject *method = NULL; PyObject *pret;
PyObject *rv = NULL; gulong ret;
PyObject *mylist = PyList_New(1); gint len;
PyObject *mynewlist = NULL;
PyObject *myargs = NULL;
PyObject *signalname = NULL;
signalname = PyString_FromString("have-data::buffer"); len = PyTuple_Size(args);
if (len < 1) {
if (PyList_SetItem(mylist, 0, signalname)) { PyErr_SetString(PyExc_TypeError, "Requires at least 1 arg");
Py_DECREF(mylist);
return NULL;
}
mynewlist = PySequence_InPlaceConcat(mylist, args);
Py_DECREF(mylist);
if (!mynewlist)
return NULL;
myargs = PyList_AsTuple(mynewlist);
Py_DECREF(mynewlist);
if (!myargs)
return NULL;
method = PyObject_GetAttrString((PyObject*)self, "connect");
if (!method) {
Py_DECREF(mylist);
return NULL; return NULL;
} }
GST_OBJECT_LOCK (pad); callback = PyTuple_GetItem(args, 0);
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "callback is not callable");
return NULL;
}
cbargs = PySequence_GetSlice(args, 1, len);
if (cbargs == NULL)
return NULL;
data = Py_BuildValue("(ON)", callback, cbargs);
if (data == NULL)
return NULL;
rv = PyObject_CallObject(method, myargs); pyg_begin_allow_threads;
if (rv) { ret = gst_pad_add_buffer_probe_full(GST_PAD(self->obj),
GST_PAD_DO_BUFFER_SIGNALS (pad)++; (GCallback) data_probe_callback_marshal, data,
GST_DEBUG_OBJECT (pad, "adding buffer probe, now %d probes", data_probe_destroy_data);
GST_PAD_DO_BUFFER_SIGNALS (pad)); pyg_end_allow_threads;
}
GST_OBJECT_UNLOCK (pad); pret = PyLong_FromUnsignedLong(ret);
Py_INCREF(pret);
Py_DECREF(myargs); return pret;
Py_DECREF(method);
return rv;
} }
%% %%
override-slot GstPadTemplate.tp_getattr override-slot GstPadTemplate.tp_getattr