[gst-devel] Re: [gst-cvs] jdahlin gst-plugins: gst-plugins/ gst-plugins/sys/v4l/

Ronald Bultje rbultje at ronald.bitfreak.net
Fri Aug 13 05:50:04 CEST 2004


Hi,

On Fri, 13 Aug 2004, Johan Dahlin wrote:
> > If you don't understand, read the bits about GstImplementsInterface in the
> > plugin writer's guide or ask me to describe why it is needed and what it
> > does. Simply removing code because you don't understand why it's there is
> > never the right solution.
>
> To be practical, what I cannot do is to cast an a v4lsrc, which
> implements GstTuner (eg GstTuner* tuner = GST_TUNER(v4lsrc)), unless the
> device is open.

I did that because you wouldn't be able to use it anyway. It's not a
GstTuner at this point. It cannot be used as one. The alternative is to
add fault codes and error handlers to each and every single interface
function that depends on runtime conditions to be useful or not. I didn't
want to do that.

If you want to do this:

GstImplementsInterface *iface = GST_IMPLEMENTS_INTERFACE (v4lsrc);
GstTuner *tuner = NULL;

if (gst_implements_interface_supported (iface, GST_TYPE_TUNER)) {
  tuner = GST_TUNER (NULL);
}

then that's fine with me. *However*, I don't care writing tens of lines of
code if it can be done in one. Go ahead if you wish. The alternative cast
macro that I'm using and the above code largely do the same thing. It's
simply convenience.

The interesting thing is that you don't see how the code path works at
all. If the supports() function always returned a static boolean (which is
always true, otherwise the whole interface wouldn't be implemented), then
why does it call that function in the first place? You could just as well
have removed this function from the casting macro and that'd at least be
clean. You could tell people to use the above code that I just gave. I'd
still kick you and revert the patch, but at least it'd be clean. Your
current solution basically tells me that you don't have a clue.

Ask. Just fucking ask. Please just ask. And I'd have told you. Don't be
ignorant and break things. I'm happy to answer such questions. Just *ASK*.

> GstImplementsInterface is totally broken
[..]

So fix it. Don't break applications, plugins and everything to hide the
fact that you think GstImplementsInterface should be done differently.

And please ask. Don't just do things.

Ronald





More information about the gstreamer-devel mailing list