[vlc-devel] [PATCH] Add marq filter to libvlc

jpd at videolan.org jpd at videolan.org
Wed Jun 24 14:18:37 CEST 2009


On Wed, Jun 24, 2009 at 11:17:34AM +0200, Cyril MATHE wrote:
> I was thinking that there was too much code lines repeat. Now it's
> exactly like you want it to be. The patch is joined to this email.

There is an important difference between API and implementation. For
the implementation I would like to suggest using an enum to enumerate
the variables like you do[1], but instead of using a switch, check for
overflow (unsigned, see if you can see why), and implement a single
two-variable setter.

For the implementation, you can then express the setters in terms of
your (private, static to the module) pvt_set_any_var(var_enum,value):

  void set_some_var(int n) { pvt_set_any_var(enum_some_var,n); }
  void set_other_var(int n) { pvt_set_any_var(enum_other_var,n); }

If your pvc_set_any_var() is static inline it'll result in (some) code
duplication but at least the compiler does it, and thus results in less
opportunity to get something wrong by typo.


[1] No need to number each: Read up on what it does when you don't.




More information about the vlc-devel mailing list