[gst-devel] Re: bufferpools

Benjamin Otte in7y118 at public.uni-hamburg.de
Fri Jan 9 05:11:02 CET 2004


On Thu, 8 Jan 2004, David Schleef wrote:

> static GstBuffer *
> gst_ximagesink_sink_bufferalloc (GstPad *pad, guint64 offset, guint
> size)
> {
>   GstBuffer *buffer;
>
>   buffer = gst_buffer_new_and_alloc (size);
>   GST_DATA_FREE_FUNC (data) = gst_ximagesink_buffer_free;
>   GST_BUFFER_POOL_PRIVATE (data) = ximagesink; /* whatever */
>
>   return buffer;
> }
>
> static void
> gst_ximagesink_buffer_free (GstData *data)
> {
>   g_free (GST_BUFFER_DATA (data));
> }
>
This last function is actually wrong, because you never free the DstData
struct. A correct function would be

static void
gst_ximagesink_buffer_free (GstData *data)
{
  g_free (GST_BUFFER_DATA (data));
  GST_BUFFER_DATA (data) = NULL;
  gst_buffer_default_free (GST_BUFFER (data));
}

which is why I still mandated adding a buffer_data_free function pointer
to GstBuffer and make the data_free function of GstBuffer call that one.

Benjamin





More information about the gstreamer-devel mailing list