configure.ac: Require python 2.3

Original commit message from CVS:
* configure.ac: Require python 2.3

* gst/gstmodule.c (python_do_pending_calls): Use PyGILState and
friends here.

* gst/gst.override (_pygst_main_quit, _pygst_main): Use these two
instead of gst_main/gst_main_quit so we can check if we're in a
mainloop or not.
This commit is contained in:
Johan Dahlin 2004-08-03 17:07:38 +00:00
parent b18efd0d22
commit 169626bb24
5 changed files with 91 additions and 18 deletions

View file

@ -1,3 +1,14 @@
2004-08-03 Johan Dahlin <johan@gnome.org>
* configure.ac: Require python 2.3
* gst/gstmodule.c (python_do_pending_calls): Use PyGILState and
friends here.
* gst/gst.override (_pygst_main_quit, _pygst_main): Use these two
instead of gst_main/gst_main_quit so we can check if we're in a
mainloop or not.
2004-08-02 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.defs:

View file

@ -34,10 +34,10 @@ AC_PROG_LIBTOOL
dnl check for python
dnl AM_PATH_PYTHON(2.2)
AM_PATH_PYTHON
AC_MSG_CHECKING(for python >= 2.2)
AC_MSG_CHECKING(for python >= 2.3)
prog="
import sys, string
minver = (2,2,0,'final',0)
minver = (2,3,0,'final',0)
if sys.version_info < minver:
sys.exit(1)
sys.exit(0)"
@ -76,12 +76,11 @@ PYGTK_H2DEF=`$PKG_CONFIG --variable=codegendir pygtk-2.0`/h2def.py
AC_SUBST(PYGTK_H2DEF)
AC_MSG_RESULT($PYGTK_H2DEF)
dnl AC_MSG_CHECKING(for pygtk codegen)
dnl PYGTK_CODEGEN="$PYTHON `$PKG_CONFIG --variable=codegendir pygtk-2.0`/codegen.py"
dnl AC_SUBST(PYGTK_CODEGEN)
dnl AC_MSG_RESULT($PYGTK_CODEGEN)
PYGTK_CODEGEN="$PYTHON \$(top_srcdir)/codegen/codegen.py"
AC_MSG_CHECKING(for pygtk codegen)
PYGTK_CODEGEN="$PYTHON `$PKG_CONFIG --variable=codegendir pygtk-2.0`/codegen.py"
dnl PYGTK_CODEGEN="$PYTHON \$(top_srcdir)/codegen/codegen.py"
AC_SUBST(PYGTK_CODEGEN)
AC_MSG_RESULT($PYGTK_CODEGEN)
dnl Interfaces
AC_MSG_CHECKING(for GStreamer interfaces include dir)

View file

@ -1,4 +1,4 @@
/* -*- Mode: C; ; c-file-style: "python" -*- */
/* -*- Mode: C; c-basic-offset: 4 -*- */
so/* gst-python
* Copyright (C) 2002 David I. Lehn
* Copyright (C) 2004 Johan Dahlin
@ -37,6 +37,33 @@ headers
extern gboolean pygst_data_from_pyobject (PyObject *object, GstData **data);
static PyObject *_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs);
GSList *mainloops = NULL;
void
_pygst_main_quit(void)
{
if (!mainloops)
g_error ("Quit more loops than there are");
else {
GMainLoop *loop = mainloops->data;
mainloops = g_slist_delete_link (mainloops, mainloops);
g_main_loop_quit (loop);
g_main_loop_unref (loop);
}
}
void
_pygst_main(void)
{
GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE);
mainloops = g_slist_prepend (mainloops, loop);
g_main_loop_run (loop);
}
%%
include
gstbin.override
@ -598,6 +625,27 @@ _wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs)
return Py_None;
}
%%
override gst_structure_get_int kwargs
static PyObject *
_wrap_gst_structure_get_int(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "fieldname", NULL };
char *fieldname;
int value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s:GstStructure.get_int",
kwlist, &fieldname))
return NULL;
if (gst_structure_get_int(pyg_boxed_get(self, GstStructure), fieldname, &value))
return PyInt_FromLong(value);
/* XXX: Raise exception? */
Py_INCREF(Py_None);
return Py_None;
}
%%
override-slot GstStructure.tp_as_mapping
static int
_wrap_gst_structure_length(PyGObject *self)
@ -885,9 +933,11 @@ override gst_main noargs
static PyObject *
_wrap_gst_main(PyObject *self)
{
pyg_unblock_threads();
gst_main();
pyg_block_threads();
Py_BEGIN_ALLOW_THREADS;
_pygst_main();
Py_END_ALLOW_THREADS;
if (PyErr_Occurred())
return NULL;
@ -896,6 +946,18 @@ _wrap_gst_main(PyObject *self)
return Py_None;
}
%%
override gst_main_quit args
static PyObject *
_wrap_gst_main_quit(PyObject *self)
{
_pygst_main_quit();
Py_INCREF(Py_None);
return Py_None;
}
%%
override-slot GstElement.tp_init kwargs
static int

View file

@ -94,9 +94,9 @@ _wrap_gst_bin_iterate(PyGObject *self)
{
int ret;
pyg_unblock_threads();
Py_BEGIN_ALLOW_THREADS;
ret = gst_bin_iterate(GST_BIN(self->obj));
pyg_block_threads();
Py_END_ALLOW_THREADS;
return PyInt_FromLong(ret);
}
%%

View file

@ -33,22 +33,23 @@ void pygst_register_classes (PyObject *d);
void pygst_add_constants(PyObject *module, const gchar *strip_prefix);
extern PyMethodDef pygst_functions[];
extern GSList *mainloops;
static gboolean
python_do_pending_calls(gpointer data)
{
gboolean quit = FALSE;
pyg_block_threads();
PyGILState_STATE state;
state = PyGILState_Ensure();
if (PyErr_CheckSignals() == -1) {
PyErr_SetNone(PyExc_KeyboardInterrupt);
quit = TRUE;
}
pyg_unblock_threads();
if (quit)
if (quit && mainloops != NULL)
gst_main_quit();
PyGILState_Release(state);
return TRUE;
}