Lua plugins - checkpoint
- From: Victor Toso <me victortoso com>
- To: grilo-list gnome org
- Subject: Lua plugins - checkpoint
- Date: Mon, 8 Jul 2013 00:50:45 -0300
Folks,
Sorry for the big e-mail. If your time is short, I guess the item 4 is
the one I would love some expertise.
So, I have implemented a few things and I would love to hear your
feedback to see if I'm going in the right way.
A little explanation about everything:
- grl-lua-factory.c: load/remove lua-plugins, get the operations from
application and pass it to lua-pluging;
- grl-lua-library.c: This is a module to lua-plugins. There are two
functions implemented: callback and fetch;
- grl-metrolyrics.lua: The plugin which I'm using to develop both
glue-codes above.
The code is here: https://github.com/victortoso/grilo-plugins [on master]
1-) I'm using lua version 5.2.2 in this project. Why ? Is the most
recent one but looks like it is one year old already.
2-) Using a table to set the plugin [0]. I really thought that this
was the easiest way possible.
e.g. The developer has to set plugin.search = "function_name" and this
would be the handler of Search operation.
[0] https://github.com/victortoso/grilo-plugins/blob/master/src/lua-factory/sources/grl-metrolyrics.lua#L27
3-) I was afraid about implementing async functions in lua-library but
it worked as in pure c (in the fetch function).
I'm just pointing this because I felt that is important to show that
async functions works fine in the glue-code.
4-) Building the Media. Currently, I'm using in lua the string
'GRL_METADATA_KEY_ARTIST' to set the artist name.
I like this as a good way to keep the standards. The lua-library
function that will build the media verify each string
and use the right function to set the media. This is a bit of
overwork, but I don't know a better way.
Actually I thought about setting the defines to be used with grilo
module [1] but it doesn't feel the right approach.
Opinions on this ?
[1] http://lua-users.org/lists/lua-l/2001-01/msg00156.html
5-) Userdata problem - case:
The lua-factory request to lua-plugin to execute a Search. when the
lua-plugin has the Media ready, it'll call
the grilo.callback. This function needs to know the
application-callback function and the plugin source.
Currently I'm passing a c pointer to lua-plugin (as userdata) and
passing it to the callback.
It is always a pointer to struct OperationSpec.
I'll change this in order to not pass a struct without meaning to lua.
I intend to register this structure from lua-factory in lua-library
right before passing the control to the lua-plugin.
To grilo.callback know which structure this operation is from, it need
some key. I intent to use the operation_id.
So, instead of userdata, I'll pass the operation id, which will be
used to get the right structure in the callback.
I guess this is it.
This week I intend to finish the item 5 and improve the item 4 as I've
done only what grl-metrolyrics needs.
The Browse, Query and Resolve operation are almost ready to go too.
After this, my idea is to write a new plugin, which I can use some
configs to set-up and others operations
that Metrolyrics does not provide.
best regards,
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]