Commit 345cd124 authored by Pavel Rojtberg's avatar Pavel Rojtberg

do not leak GstMapInfo

it is new'ed but never deleted. However it does not need to be global or
heap allocated in the first place.
parent f4c9bc8b
......@@ -146,7 +146,6 @@ protected:
GstElement* sink;
#if GST_VERSION_MAJOR > 0
GstSample* sample;
GstMapInfo* info;
#endif
GstBuffer* buffer;
GstCaps* caps;
......@@ -169,7 +168,6 @@ void CvCapture_GStreamer::init()
sink = NULL;
#if GST_VERSION_MAJOR > 0
sample = NULL;
info = new GstMapInfo;
#endif
buffer = NULL;
caps = NULL;
......@@ -318,17 +316,16 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
#if GST_VERSION_MAJOR == 0
frame->imageData = (char *)GST_BUFFER_DATA(buffer);
#else
// the data ptr in GstMapInfo is only valid throughout the mapifo objects life.
// TODO: check if reusing the mapinfo object is ok.
gboolean success = gst_buffer_map(buffer,info, (GstMapFlags)GST_MAP_READ);
// info.data ptr is valid until next grabFrame where the associated sample is unref'd
GstMapInfo info = GstMapInfo();
gboolean success = gst_buffer_map(buffer,&info, (GstMapFlags)GST_MAP_READ);
if (!success){
//something weird went wrong here. abort. abort.
//fprintf(stderr,"GStreamer: unable to map buffer");
return 0;
}
frame->imageData = (char*)info->data;
gst_buffer_unmap(buffer,info);
frame->imageData = (char*)info.data;
gst_buffer_unmap(buffer,&info);
#endif
return frame;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment