mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-03 17:18:04 +02:00
lua: add g_get_real/monotonic_time() bindings
Useful to tag objects with their creation time
This commit is contained in:
parent
6d84295fc5
commit
7c617742a9
2 changed files with 26 additions and 0 deletions
|
|
@ -38,6 +38,28 @@ get_wp_export_core (lua_State *L)
|
|||
return core;
|
||||
}
|
||||
|
||||
/* GLib */
|
||||
|
||||
static int
|
||||
glib_get_monotonic_time (lua_State *L)
|
||||
{
|
||||
lua_pushinteger (L, g_get_monotonic_time ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
glib_get_real_time (lua_State *L)
|
||||
{
|
||||
lua_pushinteger (L, g_get_real_time ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg glib_methods[] = {
|
||||
{ "get_monotonic_time", glib_get_monotonic_time },
|
||||
{ "get_real_time", glib_get_real_time },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* GSource */
|
||||
|
||||
static int
|
||||
|
|
@ -1218,6 +1240,9 @@ wp_lua_scripting_api_init (lua_State *L)
|
|||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
luaL_newlib (L, glib_methods);
|
||||
lua_setglobal (L, "GLib");
|
||||
|
||||
luaL_newlib (L, log_funcs);
|
||||
lua_setglobal (L, "WpDebug");
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ SANDBOX_EXPORT = {
|
|||
Id = Id,
|
||||
Features = Features,
|
||||
Feature = Feature,
|
||||
GLib = GLib,
|
||||
Log = WpDebug,
|
||||
Core = WpCore,
|
||||
Plugin = WpPlugin_find,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue