gst/gstbuffer.override: handle the data correctly

Original commit message from CVS:
* gst/gstbuffer.override:
handle the data correctly
This commit is contained in:
Benjamin Otte 2005-04-25 02:36:27 +00:00
parent aedd023474
commit 3843709727
2 changed files with 11 additions and 10 deletions

View file

@ -1,3 +1,8 @@
2005-04-25 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstbuffer.override:
handle the data correctly
2005-04-12 Thomas Vander Stichele <thomas at apestaart dot org> 2005-04-12 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.defs: * gst/gst.defs:

View file

@ -49,13 +49,14 @@ _wrap_gst_buffer_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
&data, &size, &buf_size)) &data, &size, &buf_size))
return -1; return -1;
if (size < 0) {
PyErr_SetString(PyExc_TypeError, "buffer size must be >= 0");
return -1;
}
self->gtype = GST_TYPE_BUFFER; self->gtype = GST_TYPE_BUFFER;
self->free_on_dealloc = FALSE; self->free_on_dealloc = FALSE;
if (buf_size != -1) self->boxed = gst_buffer_new_and_alloc(buf_size > size ? buf_size : size);
self->boxed = gst_buffer_new_and_alloc(buf_size);
else
self->boxed = gst_buffer_new();
if (!self->boxed) { if (!self->boxed) {
PyErr_SetString(PyExc_RuntimeError, "could not create GstBuffer object"); PyErr_SetString(PyExc_RuntimeError, "could not create GstBuffer object");
@ -65,12 +66,7 @@ _wrap_gst_buffer_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
if (data == NULL) if (data == NULL)
return 0; return 0;
if (buf_size != -1 && buf_size != size) { memcpy (GST_BUFFER_DATA (self->boxed), data, size);
PyErr_Format(PyExc_TypeError, "data must be of length %d, not %d", size, buf_size);
return -1;
}
GST_BUFFER_DATA (self->boxed) = data;
GST_BUFFER_SIZE (self->boxed) = size; GST_BUFFER_SIZE (self->boxed) = size;
return 0; return 0;