mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
Merge branch 'master' of ssh://git.freedesktop.org/git/gstreamer/gst-python
This commit is contained in:
commit
01ce2d2060
1 changed files with 35 additions and 23 deletions
|
@ -25,6 +25,7 @@
|
||||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
PyTypeObject *_PyGstElement_Type;
|
PyTypeObject *_PyGstElement_Type;
|
||||||
#define PyGstElement_Type (*_PyGstElement_Type)
|
#define PyGstElement_Type (*_PyGstElement_Type)
|
||||||
|
@ -40,35 +41,46 @@ static PyObject *element;
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
np_init_pygobject (void)
|
np_init_pygobject (void)
|
||||||
{
|
{
|
||||||
PyObject *gobject = PyImport_ImportModule ("gobject");
|
gboolean res = FALSE;
|
||||||
gboolean res = TRUE;
|
PyObject *gobject = NULL;
|
||||||
|
PyObject *main_module = NULL;
|
||||||
|
PyObject *mdict = NULL;
|
||||||
|
|
||||||
if (gobject != NULL) {
|
gobject = PyImport_ImportModule ("gobject");
|
||||||
PyObject *mdict = PyModule_GetDict (gobject);
|
if (gobject == NULL) {
|
||||||
PyObject *cobject = PyDict_GetItemString (mdict, "_PyGObject_API");
|
|
||||||
if (PyCObject_Check (cobject)) {
|
|
||||||
_PyGObject_API =
|
|
||||||
(struct _PyGObject_Functions *) PyCObject_AsVoidPtr (cobject);
|
|
||||||
} else {
|
|
||||||
PyErr_SetString (PyExc_RuntimeError,
|
|
||||||
"could not find _PyGObject_API object");
|
|
||||||
PyErr_Print ();
|
|
||||||
res = FALSE;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
if (!(PyObject_CallMethod (gobject, "threads_init", NULL, NULL))) {
|
|
||||||
PyErr_SetString (PyExc_RuntimeError, "Could not initialize threads");
|
|
||||||
PyErr_Print ();
|
|
||||||
res = FALSE;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PyErr_Print ();
|
PyErr_Print ();
|
||||||
GST_WARNING ("could not import gobject");
|
GST_WARNING ("could not import gobject");
|
||||||
res = FALSE;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main_module = PyImport_AddModule ("__main__");
|
||||||
|
mdict = PyModule_GetDict (gobject);
|
||||||
|
|
||||||
|
PyObject *cobject = PyDict_GetItemString (mdict, "_PyGObject_API");
|
||||||
|
if (cobject == NULL) {
|
||||||
|
GST_WARNING ("could not find _PyGObject_API");
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
|
_PyGObject_API =
|
||||||
|
(struct _PyGObject_Functions *) PyCObject_AsVoidPtr (cobject);
|
||||||
|
if (_PyGObject_API == NULL) {
|
||||||
|
PyErr_Print ();
|
||||||
|
GST_WARNING ("_PyGObject_API is not a valid CObject");
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(PyObject_CallMethod (gobject, "threads_init", NULL, NULL))) {
|
||||||
|
PyErr_Print ();
|
||||||
|
GST_WARNING ("could not initialize threads");
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = TRUE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
Py_XDECREF (gobject);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue