mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
fix callback args so tests work
Original commit message from CVS: fix callback args so tests work
This commit is contained in:
parent
4c20bb90a5
commit
b6acbfe0a1
2 changed files with 37 additions and 6 deletions
|
@ -627,17 +627,27 @@ probe_handler_marshal(GstProbe *probe, GstData **data, gpointer user_data)
|
|||
PyGILState_STATE state;
|
||||
PyObject *callback, *args;
|
||||
PyObject *ret;
|
||||
PyObject *py_user_data;
|
||||
gboolean res;
|
||||
gint len, i;
|
||||
|
||||
g_return_val_if_fail(user_data != NULL, FALSE);
|
||||
|
||||
state = pyg_gil_state_ensure();
|
||||
|
||||
callback = PyTuple_GetItem((PyObject *)user_data, 0);
|
||||
args = Py_BuildValue("(NNO)",
|
||||
py_user_data = (PyObject *) user_data;
|
||||
|
||||
callback = PyTuple_GetItem(py_user_data, 0);
|
||||
args = Py_BuildValue("(NN)",
|
||||
pyg_boxed_new(GST_TYPE_PROBE, probe, TRUE, TRUE),
|
||||
pyg_boxed_new(GST_TYPE_DATA, *data, TRUE, TRUE),
|
||||
PyTuple_GetItem((PyObject *)user_data, 1));
|
||||
pyg_boxed_new(GST_TYPE_DATA, *data, TRUE, TRUE));
|
||||
|
||||
len = PyTuple_Size(py_user_data);
|
||||
for (i = 1; i < len; ++i) {
|
||||
PyObject *tuple = args;
|
||||
args = PySequence_Concat(tuple, PyTuple_GetItem(py_user_data, i));
|
||||
Py_DECREF(tuple);
|
||||
}
|
||||
ret = PyObject_CallObject(callback, args);
|
||||
|
||||
if (!ret) {
|
||||
|
|
|
@ -19,7 +19,16 @@ class ProbeTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, probe.perform, None)
|
||||
self.assertRaises(TypeError, probe.perform, "nodata")
|
||||
|
||||
def testPerform(self):
|
||||
def testPerformNoArg(self):
|
||||
probe = gst.Probe(True, self._probe_callback_no_arg)
|
||||
buffer = gst.Buffer()
|
||||
probe.perform(buffer)
|
||||
self.assertEqual(self._no_arg, None)
|
||||
|
||||
def _probe_callback_no_arg(self, probe, data):
|
||||
self._no_arg = None
|
||||
|
||||
def testPerformOneArg(self):
|
||||
probe = gst.Probe(True, self._probe_callback, "yeeha")
|
||||
buffer = gst.Buffer()
|
||||
probe.perform(buffer)
|
||||
|
@ -28,6 +37,18 @@ class ProbeTest(unittest.TestCase):
|
|||
def _probe_callback(self, probe, data, result):
|
||||
self._probe_result = result
|
||||
return True
|
||||
|
||||
|
||||
def testPerformTwoArgs(self):
|
||||
probe = gst.Probe(True, self._probe_callback_two, "yeeha", "works")
|
||||
buffer = gst.Buffer()
|
||||
probe.perform(buffer)
|
||||
self.assertEqual(self._probe_result1, "yeeha")
|
||||
self.assertEqual(self._probe_result2, "works")
|
||||
|
||||
def _probe_callback_two(self, probe, data, result1, result2):
|
||||
self._probe_result1 = result1
|
||||
self._probe_result2 = result2
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue