3
votes

I have a pipeline, which takes data from webcam and process it.

For the processing i need to pull that buffer to appsink and push it into pipeline by using appsrc element.

While pushing i had used gst_buffer_new_wrapped function.

Then a new buffer is allocated every time i am pushing the data. But how to free that memory is the problem.

I had tried gst_buffer_unref(buffer);

Then got below error.

 Error in `./uuHiesSoaServer': free(): invalid pointer: 0x00007fddf52f6000 

I had take the data into an unsigned char pointer and then wrapped into a gstbuffer based on the size.

Now how to free the allocated memory?

g_signal_emit_by_name (Source, "push-buffer", Buffer, &ret);

I had used above function for pushing data into Source(appsrc).

That function will continuously call on a separate thread.

When data available to it, then the thread function will create a buffer using

gst_buffer_new_wrapped((void *)data, Size);

When checking in valgrind, for memory leaks, above line was shown as a leak.

How to solve this?

1

1 Answers

1
votes

How do you push the buffer into appsrc?

If you use gst_app_src_push_buffer function I guess you do not have to free resources because gst_app_src_push_buffer will own the buffer (which means it also frees it) Check this example

If you use need-data callback you may need to free data - check this example

HTH