python: Fix some locking problems

Add some python pyg_begin_allow_threads/end_allow_threads when calling into some gstreamer functions that might
call into python.
This commit is contained in:
Jan Schmidt 2009-04-18 16:39:42 +01:00
parent ec692ee329
commit 777a4d59ec
3 changed files with 21 additions and 7 deletions

View file

@ -232,7 +232,10 @@ pad_name_from_object (PyObject *object, const gchar **name)
*name = PyString_AsString (object);
return TRUE;
} else if (pygobject_check (object, &PyGstPad_Type)) {
*name = gst_object_get_name (GST_OBJECT (pygobject_get (object)));
GstObject *obj = GST_OBJECT (pygobject_get (object));
pyg_begin_allow_threads;
*name = gst_object_get_name (obj);
pyg_end_allow_threads;
return TRUE;
}
PyErr_SetString(PyExc_TypeError, "argument could not be converted to a pad");

View file

@ -35,7 +35,13 @@ _wrap_gst_message_tp_repr (PyGstMiniObject *self)
structure_str = msg->structure ? gst_structure_to_string (msg->structure)
: g_strdup ("(none)");
src_str = msg->src ? gst_object_get_name (msg->src) : g_strdup ("(no src)");
if (msg->src) {
pyg_begin_allow_threads;
src_str = gst_object_get_name (msg->src);
pyg_end_allow_threads;
} else {
src_str = g_strdup ("(no src)");
}
repr = g_strdup_printf ("<gst.Message %s from %s at %p>",
structure_str, src_str, msg);

View file

@ -656,24 +656,29 @@ _wrap_gst_pad_tp_repr (PyGObject *self)
gchar *elementname = NULL;
pad = GST_PAD(self->obj);
parent = GST_ELEMENT (gst_pad_get_parent (pad));
pyg_begin_allow_threads;
padname = gst_pad_get_name (pad);
parent = GST_ELEMENT (gst_pad_get_parent (pad));
if (parent)
elementname = gst_element_get_name (parent);
elementname = gst_element_get_name (parent);
buf = g_strdup_printf ("<GstPad (%s:%s) at %lx>",
parent ? elementname : "---",
padname, (long) self->obj);
g_free(padname);
if (parent) {
gst_object_unref (parent);
g_free(elementname);
g_free(elementname);
}
g_free(padname);
pyg_end_allow_threads;
retval = PyString_FromString(buf);
g_free(buf);
return retval;
}