[gst-devel] Upstream negotiation

Michael Smith msmith at fluendo.com
Tue Nov 28 16:28:58 CET 2006


On Tue, 2006-11-28 at 15:21 +0000, Will Newton wrote:
> Hi all,
> 
> I'm writing a plugin to interface to a hardware device that needs
> buffers alloced in a certain way. So I wrote a buffer_alloc function
> for my plugin, which I thought looked like the right thing to do. I
> setup a pipeline like this:
> 
> gst-launch filesrc location=foo.mp3 ! mysink
> 
> But my buffer_alloc function is not called as I had expected, filesrc
> just does gst_buffer_new() and passes the buffer to me regardless that
> my sink has a buffer_alloc function. Is there any way to force my
> buffer_alloc function to be used? Is filesrc correct to alloc buffers
> in this way?


Normally, elements should do buffer allocation properly, but a) many
don't, and b) that is not enough by itself to ensure that the buffers
will be of the right type (it's not always possible).

The right thing to do is, in your chain function, check what type the
buffer is. If it's one of your custom-allocated buffers, great! Just use
it. If it isn't, then at that point you should allocate a buffer, and
copy the contents of the incoming buffer into your buffer before using
it.

Mike






More information about the gstreamer-devel mailing list