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.
This commit is contained in:
parent
f4c9bc8bc4
commit
345cd1242f
@ -146,7 +146,6 @@ protected:
|
|||||||
GstElement* sink;
|
GstElement* sink;
|
||||||
#if GST_VERSION_MAJOR > 0
|
#if GST_VERSION_MAJOR > 0
|
||||||
GstSample* sample;
|
GstSample* sample;
|
||||||
GstMapInfo* info;
|
|
||||||
#endif
|
#endif
|
||||||
GstBuffer* buffer;
|
GstBuffer* buffer;
|
||||||
GstCaps* caps;
|
GstCaps* caps;
|
||||||
@ -169,7 +168,6 @@ void CvCapture_GStreamer::init()
|
|||||||
sink = NULL;
|
sink = NULL;
|
||||||
#if GST_VERSION_MAJOR > 0
|
#if GST_VERSION_MAJOR > 0
|
||||||
sample = NULL;
|
sample = NULL;
|
||||||
info = new GstMapInfo;
|
|
||||||
#endif
|
#endif
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
caps = NULL;
|
caps = NULL;
|
||||||
@ -318,17 +316,16 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
|||||||
#if GST_VERSION_MAJOR == 0
|
#if GST_VERSION_MAJOR == 0
|
||||||
frame->imageData = (char *)GST_BUFFER_DATA(buffer);
|
frame->imageData = (char *)GST_BUFFER_DATA(buffer);
|
||||||
#else
|
#else
|
||||||
// the data ptr in GstMapInfo is only valid throughout the mapifo objects life.
|
// info.data ptr is valid until next grabFrame where the associated sample is unref'd
|
||||||
// TODO: check if reusing the mapinfo object is ok.
|
GstMapInfo info = GstMapInfo();
|
||||||
|
gboolean success = gst_buffer_map(buffer,&info, (GstMapFlags)GST_MAP_READ);
|
||||||
gboolean success = gst_buffer_map(buffer,info, (GstMapFlags)GST_MAP_READ);
|
|
||||||
if (!success){
|
if (!success){
|
||||||
//something weird went wrong here. abort. abort.
|
//something weird went wrong here. abort. abort.
|
||||||
//fprintf(stderr,"GStreamer: unable to map buffer");
|
//fprintf(stderr,"GStreamer: unable to map buffer");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
frame->imageData = (char*)info->data;
|
frame->imageData = (char*)info.data;
|
||||||
gst_buffer_unmap(buffer,info);
|
gst_buffer_unmap(buffer,&info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user