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:
* gst/pygstminiobject.c:
remove the hash table for miniobjects - since we can't get notified
}
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;
}
%%
PyObject *PyGstExc_LinkError = NULL;
PyObject *PyGstExc_AddError = NULL;
+PyObject *PyGstExc_QueryError = NULL;
PyObject *PyGstExc_RemoveError = NULL;
PyObject *PyGstExc_PluginNotFoundError = NULL;
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();
Py_XDECREF(PyGstExc_LinkError);
Py_XDECREF(PyGstExc_AddError);
Py_XDECREF(PyGstExc_RemoveError);
+ Py_XDECREF(PyGstExc_QueryError);
Py_XDECREF(PyGstExc_PluginNotFoundError);
return;
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);
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):
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)