[MPlayer-G2-dev] module_list vs. gui

Arpi arpi at thot.banki.hu
Tue Aug 12 20:27:47 CEST 2003


Hi,

As I already found it, and tdoay Albeu asked too, there is a problem
with the current config element type MODULE_LIST.
The current code uses a function to find modules by name, but it's not
useful for guis where you want to list the available modules.

Let's see what are our options:
- find_module_by_name() (current) - not good for gui (can't list modules)
- pointer to module_t array - not good for code, there may be multiple
  lists, dinamically loadable modules (and as we discussed earlier, a CLI
  shouldnt load all those, only the explicitly named modules), and special
  hidden modules (for internal use, like null or vf_vo2/vf_vd wrappers)
- enumeration func: a function which returns a single module at a call, and
  can be called until you get null, to get all available modules
  (you should pass the previous return value (or null at 1st call) as
  parameter, to make it thread safe / reentrant)

I would go for a mix of the 1st and 3rd option, ie. an enumeration function
which can also do searching. Something like the good old findfirst/findnext
of DOS:

module_t* enum_modules(module_t* prev, char* mod_name, int type)
  prev: the result of previous call, NULL for 1st call
  mod_name: name of the module we're searching for (when explicitly named),
     or NULL (when we list all modules)
  type: some type value, like 0=static(builtin modules), 1=dinamic -1=internal
     (note: this field shouldn't be changed between the first and other
     calls, and implementations may read it only at 1st call)
     Mayeb it could be flags instead, ie 1, 2, 4, so they can be OR'ed

So listing public (not hidden/internal) static and dinamic modules:
for(t=0;t<=1;t++){
   module_t* prev=NULL;
   while((prev=enum_modules(prev,NULL,t))){
	printf("[%s] %s\n",t?"dinamic":"static", prev->name);
   }
}

And searching for a named module:
mod=enum_modules(NULL,"vf_vo",0);

You will ask why don't make 2 functions instead, one for search, and one for
list/enumerate. The answer is simple: there is only one 'priv' (pointer)
parameter in the config_t struct, and adding one more only for this is silly.


A'rpi / Astral & ESP-team

--
Developer of MPlayer G2, the Movie Framework for all - http://www.MPlayerHQ.hu



More information about the MPlayer-G2-dev mailing list