[gst-devel] question re: buffer handling
Thomas Vander Stichele
thomas at urgent.rug.ac.be
Thu Aug 29 08:01:01 CEST 2002
Hi,
> > a) should each plug-in that wants to do in-place editing for efficiency
> > check if it's allowed to by himself and make a copy if necessary ?
>
> This would seem to be correct. I'm only just getting into gstreamer so
> I've been reading the manual, and chapter 10 of the application
> development manual says:
Heh, it's great that you comment on the manual ! I've been so wrapped up
in internals that I rarely bother to check it anymore, I should do that
more often. Thanks for replying, and let us know if you find anything in
there that's not clear or right so we can work on it.
> A more complex case is when the filter modifies the data in place. It
> does so and simply passes on the buffer to the next element. This is
> just as easy to deal with. An element that works in place has to be
> careful when the buffer is used in more than one element; a copy on
> write has to made in this situation.
>
> Since buffers are reference counted, you could use that to see if you
> are the only one holding a reference (I think).
Yeah, theoretically, but this could get nasty very quickly. I don't know
if it's safe to use the reference count for this, and you'd probably have
to do locking for it to work.
I've thought about it some more, and like to make this process as
transparent as possible. At this moment, I made some changes to tee, and
I changed my plug-in to make a copy of the buffer when the buffer is
read-only.
IMO, this sort of code should actually go in the code that passes buffers
between elements; ie. gst_pad_push and gst_pad_pull.
I would let an element declare if it does in-place editing through a
property or flag or whatever, and the code for the buffer passing could
then check if the buffer is read-only and the element receiving the buffer
does in-place-edits. In that case, it should make a copy and unref the
original one.
Would that work ?
The other thing that's needed then is the change to tee I made, which I
think is reasonable; if tee sends out the same buffer to more than one
pad, all of those buffers should be read-only.
Thomas
--
The Dave/Dina Project : future TV today ! - http://davedina.apestaart.org/
<-*- -*->
You came in just like smoke
With a little come on come on
come on in your walk
come on
<-*- thomas at apestaart.org -*->
URGent, the best radio on the Internet - 24/7 ! - http://urgent.rug.ac.be/
More information about the gstreamer-devel
mailing list