[MPlayer-dev-eng] [PATCH] libbs2b audio filter

Uoti Urpala uoti.urpala at pp1.inet.fi
Sat Mar 7 13:10:17 CET 2009


On Sat, 2009-03-07 at 13:07 +0300, Andrew Savchenko wrote:
> On Friday 06 March 2009 17:07, Uoti Urpala wrote:
> > That means the 
> > compiler handles it as if the argument types had been declared
> > to be "t_bs2bdp, void *". You only don't get a warning about
> > this mismatch because you didn't specify the types normally.
> 
> Yes and no. Types are not fully specified at compile type. Types 
> specification is required mostly for optimizations and as 
> protection from programming errors. In practice compiler will push 
> arguments in the stack and jump to the library function enty 
> point. Without type check it is up to programmer to verify they 
> are correct.
> 
> > In short you simply should not use function declarations with
> > empty argument lists. The possibility to do that at all is
> > marked as an obsolescent feature in the C standard.
> 
> Sincerelly I'm not completely satisfied with current solution, but 
> I see no better way. We have rather long discussion here, but it 
> is mostly theoretical. Have you any practical idea how to avoid 
> this and code duplication at the same time?

A better way to write the "dirty" solution is to declare the function
pointer to take a "void *" second argument. That will produce warnings,
but it is something that _merits_ a warning even if it will work in most
practical implementations. You shouldn't add more questionable stuff
just to prevent the compiler from noticing what you already have.

I think using a switch to make a "clean" solution would not be too
cumbersome in this case. It's possible this would worsen performance,
but that's only because of the existing already ridiculously inefficient
function-call-per-sample usage. If that main inefficiency is fixed later
then the switch will have no performance impact either.




More information about the MPlayer-dev-eng mailing list