add gst.QueryError and use it

Original commit message from CVS:

* gst/gstelement.override:
* gst/pygstexception.c:
* gst/pygstexception.h:
* testsuite/test_element.py:
add gst.QueryError and use it
* testsuite/test_pad.py:
add some tests that show comparison between two different
Python objects wrapping the same MiniObject
This commit is contained in:
Thomas Vander Stichele 2005-10-27 09:51:18 +00:00
parent 723f72b0fb
commit f2a5a97ac3
6 changed files with 45 additions and 11 deletions

View file

@ -1,3 +1,14 @@
2005-10-27 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* gst/gstelement.override:
* gst/pygstexception.c:
* gst/pygstexception.h:
* testsuite/test_element.py:
add gst.QueryError and use it
* testsuite/test_pad.py:
add some tests that show comparison between two different
Python objects wrapping the same MiniObject
2005-10-27 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* gst/gst.override:

View file

@ -374,15 +374,15 @@ _wrap_gst_element_query_position (PyGObject *self, PyObject *args)
}
ret = PyList_New(0);
if ((gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur))) {
PyList_Append(ret, PyLong_FromLongLong(cur));
PyList_Append(ret, pyg_enum_from_gtype (GST_TYPE_FORMAT, format ));
} else {
g_print("FIXME: query failed\n");
Py_INCREF(Py_None);
ret = Py_None;
if (!(gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur))) {
PyErr_Format(PyGstExc_QueryError,
"query failed");
return NULL;
}
PyList_Append(ret, PyLong_FromLongLong(cur));
PyList_Append(ret, pyg_enum_from_gtype (GST_TYPE_FORMAT, format ));
return ret;
}
%%

View file

@ -26,6 +26,7 @@
PyObject *PyGstExc_LinkError = NULL;
PyObject *PyGstExc_AddError = NULL;
PyObject *PyGstExc_QueryError = NULL;
PyObject *PyGstExc_RemoveError = NULL;
PyObject *PyGstExc_PluginNotFoundError = NULL;
@ -189,6 +190,18 @@ pygst_exceptions_register_classes(PyObject *d)
goto exception;
Py_DECREF(PyGstExc_RemoveError);
/* register gst.QueryError */
PyGstExc_QueryError = PyErr_NewException("gst.QueryError",
PyExc_Exception, NULL);
if (PyGstExc_QueryError == NULL)
goto exception;
if (PyDict_SetItemString(d, "QueryError", PyGstExc_QueryError) < 0)
goto exception;
Py_DECREF(PyGstExc_QueryError);
/* register gst.PluginNotFoundError */
dict = PyDict_New();
@ -219,6 +232,7 @@ exception:
Py_XDECREF(PyGstExc_LinkError);
Py_XDECREF(PyGstExc_AddError);
Py_XDECREF(PyGstExc_RemoveError);
Py_XDECREF(PyGstExc_QueryError);
Py_XDECREF(PyGstExc_PluginNotFoundError);
return;

View file

@ -27,6 +27,7 @@
extern PyObject *PyGstExc_LinkError;
extern PyObject *PyGstExc_AddError;
extern PyObject *PyGstExc_RemoveError;
extern PyObject *PyGstExc_QueryError;
extern PyObject *PyGstExc_PluginNotFoundError;
void pygst_exceptions_register_classes(PyObject *d);

View file

@ -197,8 +197,8 @@ class QueryTest(TestCase):
self.assertEquals(sys.getrefcount(self.element), 3)
assert res
assert res[0] == 0
res = self.element.query_position(gst.FORMAT_TIME)
assert not res
self.assertRaises(gst.QueryError, self.element.query_position,
gst.FORMAT_TIME)
self.gccollect()
class QueueTest(TestCase):

View file

@ -128,14 +128,22 @@ class PadPushLinkedTest(TestCase):
self.assertEquals(len(self.buffers), 0)
def testTrueProbe(self):
id = self.src.add_buffer_probe(self._probe_handler, True)
probe_id = self.src.add_buffer_probe(self._probe_handler, True)
self.buffer = gst.Buffer()
self.assertEquals(self.buffer.__grefcount__, 1)
self.assertEquals(self.src.push(self.buffer), gst.FLOW_OK)
# one refcount is held by our scope, another is held on
# self.buffers through _chain_func
self.assertEquals(self.buffer.__grefcount__, 2)
self.src.remove_buffer_probe(id)
# they are not the same Python object ...
self.failIf(self.buffer is self.buffers[0])
self.failIf(id(self.buffer) == id(self.buffers[0]))
# ... but they wrap the same GstBuffer
self.failUnless(self.buffer == self.buffers[0])
self.assertEquals(repr(self.buffer), repr(self.buffers[0]))
self.src.remove_buffer_probe(probe_id)
self.assertEquals(len(self.buffers), 1)
self.buffers = None
self.assertEquals(self.buffer.__grefcount__, 1)