Use pyg_gil_state_*

Original commit message from CVS:
Use pyg_gil_state_*
This commit is contained in:
Johan Dahlin 2004-10-07 10:05:12 +00:00
parent a1f058c663
commit e08b8d1b67
2 changed files with 30 additions and 22 deletions

View file

@ -29,10 +29,11 @@ call_link_function (GstPad *pad, GstCaps *caps)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
GstPadLinkReturn ret; GstPadLinkReturn ret;
PyGILState_STATE state;
function = pad_private(pad)->link_function; function = pad_private(pad)->link_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = (PyObject*)PyObject_CallFunction (function, retval = (PyObject*)PyObject_CallFunction (function,
"OO", "OO",
@ -41,13 +42,13 @@ call_link_function (GstPad *pad, GstCaps *caps)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
ret = PyInt_AsLong(retval); ret = PyInt_AsLong(retval);
pyg_unblock_threads(); pyg_gil_state_release(state);
return ret; return ret;
} }
@ -88,10 +89,11 @@ static void
call_chain_function(GstPad *pad, GstBuffer *buf) call_chain_function(GstPad *pad, GstBuffer *buf)
{ {
PyObject *function; PyObject *function;
PyGILState_STATE state;
function = pad_private(pad)->chain_function; function = pad_private(pad)->chain_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
PyObject_CallFunction (function, PyObject_CallFunction (function,
"OO", "OO",
@ -100,11 +102,11 @@ call_chain_function(GstPad *pad, GstBuffer *buf)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return; return;
} }
pyg_unblock_threads(); pyg_gil_state_release(state);
} }
static PyObject* static PyObject*
@ -145,10 +147,11 @@ call_event_function (GstPad *pad, GstEvent *event)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
gboolean ret; gboolean ret;
PyGILState_STATE state;
function = pad_private(pad)->event_function; function = pad_private(pad)->event_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = PyObject_CallFunction (function, retval = PyObject_CallFunction (function,
"OO", "OO",
@ -157,13 +160,13 @@ call_event_function (GstPad *pad, GstEvent *event)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return FALSE; return FALSE;
} }
ret = PyInt_AsLong(retval); ret = PyInt_AsLong(retval);
pyg_unblock_threads(); pyg_gil_state_release(state);
return ret; return ret;
} }
@ -206,10 +209,11 @@ call_get_function (GstPad *pad)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
GstData *data = NULL; GstData *data = NULL;
PyGILState_STATE state;
function = pad_private(pad)->get_function; function = pad_private(pad)->get_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad); retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad);
@ -223,7 +227,7 @@ call_get_function (GstPad *pad)
pygst_data_from_pyobject(retval, &data); pygst_data_from_pyobject(retval, &data);
bail: bail:
pyg_unblock_threads(); pyg_gil_state_release(state);
return data; return data;
} }

View file

@ -29,10 +29,11 @@ call_link_function (GstPad *pad, GstCaps *caps)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
GstPadLinkReturn ret; GstPadLinkReturn ret;
PyGILState_STATE state;
function = pad_private(pad)->link_function; function = pad_private(pad)->link_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = (PyObject*)PyObject_CallFunction (function, retval = (PyObject*)PyObject_CallFunction (function,
"OO", "OO",
@ -41,13 +42,13 @@ call_link_function (GstPad *pad, GstCaps *caps)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
ret = PyInt_AsLong(retval); ret = PyInt_AsLong(retval);
pyg_unblock_threads(); pyg_gil_state_release(state);
return ret; return ret;
} }
@ -88,10 +89,11 @@ static void
call_chain_function(GstPad *pad, GstBuffer *buf) call_chain_function(GstPad *pad, GstBuffer *buf)
{ {
PyObject *function; PyObject *function;
PyGILState_STATE state;
function = pad_private(pad)->chain_function; function = pad_private(pad)->chain_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
PyObject_CallFunction (function, PyObject_CallFunction (function,
"OO", "OO",
@ -100,11 +102,11 @@ call_chain_function(GstPad *pad, GstBuffer *buf)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return; return;
} }
pyg_unblock_threads(); pyg_gil_state_release(state);
} }
static PyObject* static PyObject*
@ -145,10 +147,11 @@ call_event_function (GstPad *pad, GstEvent *event)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
gboolean ret; gboolean ret;
PyGILState_STATE state;
function = pad_private(pad)->event_function; function = pad_private(pad)->event_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = PyObject_CallFunction (function, retval = PyObject_CallFunction (function,
"OO", "OO",
@ -157,13 +160,13 @@ call_event_function (GstPad *pad, GstEvent *event)
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
PyErr_Print (); PyErr_Print ();
pyg_unblock_threads(); pyg_gil_state_release(state);
return FALSE; return FALSE;
} }
ret = PyInt_AsLong(retval); ret = PyInt_AsLong(retval);
pyg_unblock_threads(); pyg_gil_state_release(state);
return ret; return ret;
} }
@ -206,10 +209,11 @@ call_get_function (GstPad *pad)
PyObject *function; PyObject *function;
PyObject *retval; PyObject *retval;
GstData *data = NULL; GstData *data = NULL;
PyGILState_STATE state;
function = pad_private(pad)->get_function; function = pad_private(pad)->get_function;
pyg_block_threads(); state = pyg_gil_state_ensure();
retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad); retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad);
@ -223,7 +227,7 @@ call_get_function (GstPad *pad)
pygst_data_from_pyobject(retval, &data); pygst_data_from_pyobject(retval, &data);
bail: bail:
pyg_unblock_threads(); pyg_gil_state_release(state);
return data; return data;
} }