g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (transform->out_cvImage != NULL, GST_FLOW_ERROR);
- gst_buffer_map (inbuf, &in_info, GST_MAP_READ);
- transform->cvImage->imageData = (char *) in_info.data;
+ if (!gst_buffer_map (inbuf, &in_info, GST_MAP_READ))
+ goto inbuf_map_failed;
+
+ if (!gst_buffer_map (outbuf, &out_info, GST_MAP_WRITE))
+ goto outbuf_map_failed;
- gst_buffer_map (outbuf, &out_info, GST_MAP_WRITE);
+ transform->cvImage->imageData = (char *) in_info.data;
transform->out_cvImage->imageData = (char *) out_info.data;
ret = fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf,
gst_buffer_unmap (outbuf, &out_info);
return ret;
+
+inbuf_map_failed:
+ GST_ELEMENT_ERROR (transform, RESOURCE, READ,
+ ("Failed to map buffer for reading"), (NULL));
+ return GST_FLOW_ERROR;
+
+outbuf_map_failed:
+ GST_ELEMENT_ERROR (transform, RESOURCE, WRITE,
+ ("Failed to map buffer for writing"), (NULL));
+ gst_buffer_unmap (inbuf, &in_info);
+ return GST_FLOW_ERROR;
}
static GstFlowReturn
/* TODO this is not always needed and should be solved at BaseTransform
* level */
buffer = gst_buffer_make_writable (buffer);
+ if (!gst_buffer_map (buffer, &info, GST_MAP_READWRITE))
+ goto map_failed;
- gst_buffer_map (buffer, &info, GST_MAP_READWRITE);
transform->cvImage->imageData = (char *) info.data;
/* FIXME how to release buffer? */
gst_buffer_unmap (buffer, &info);
return ret;
+
+map_failed:
+ GST_ELEMENT_ERROR (transform, RESOURCE, WRITE,
+ ("Failed to map buffer for reading and writing"), (NULL));
+ return GST_FLOW_ERROR;
}
static gboolean