summaryrefslogtreecommitdiffstats
path: root/conf.d
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2017-08-16 18:25:05 +0200
committerFulup Ar Foll <fulup@iot.bzh>2017-08-16 18:25:05 +0200
commit61f0f263c335ad403c6693a1b8b6f5428ac180a8 (patch)
tree80b49b996a1a67f164643d6fdac5645801cc6fe5 /conf.d
parent4ca8fd4015479fa758a789d137a693c30fec8cae (diff)
Fixed LUA Nested Table Issues. Added LUA2C for User Defined Plugins
Diffstat (limited to 'conf.d')
-rw-r--r--conf.d/cmake/config.cmake16
-rw-r--r--conf.d/project/config.d/onload-audio-control.json6
-rw-r--r--conf.d/project/lua.d/onload-audio-controls.lua25
3 files changed, 28 insertions, 19 deletions
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 73a00f6..4719486 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -65,9 +65,9 @@ set (PKG_REQUIRED_LIST
lua>=5.3
)
+
# Define CONTROL_CDEV_NAME should match MOST driver values
# ---------------------------------------------------------
- set(LUA_COMPILER "luac5.3" CACHE STRING "LUA syntaxe check")
add_compile_options(-DCONTROL_ONLOAD_DEFAULT="onload-default")
add_compile_options(-DCONTROL_MAXPATH_LEN=255)
add_compile_options(-DCONTROL_DOSCRIPT_PRE="doscript")
@@ -75,9 +75,17 @@ set (PKG_REQUIRED_LIST
add_compile_options(-DCONTROL_CONFIG_POST="control" )
add_compile_options(-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/config.d:${CMAKE_INSTALL_PREFIX}/controler/config.d")
- add_compile_options(-DCONTROL_LUA_EVENT="luaevt")
- add_compile_options(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/lua.d:${CMAKE_INSTALL_PREFIX}/controler/ctl-lua.d")
-
+
+ set(CONTROL_SUPPORT_LUA 1 CACHE BOOL "Active or not LUA Support")
+ if(CONTROL_SUPPORT_LUA)
+ set(LUA_COMPILER "luac5.3" CACHE STRING "LUA syntaxe check")
+ add_compile_options(-DCONTROL_SUPPORT_LUA)
+ add_compile_options(-DCONTROL_LUA_EVENT="luaevt")
+ add_compile_options(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/lua.d:${CMAKE_INSTALL_PREFIX}/controler/ctl-lua.d")
+ else(CONTROL_SUPPORT_LUA)
+ message(STATUS "Warning: LUA Without Support ")
+ endif(CONTROL_SUPPORT_LUA)
+
set (CTL_PLUGIN_PRE "ctl-" CACHE STRING "Prefix for Controler share plugin")
set (CTL_PLUGIN_EXT ".ctlso" CACHE STRING "Postfix for Controler share plugin")
add_compile_options(-DCTL_PLUGIN_MAGIC=2468013579)
diff --git a/conf.d/project/config.d/onload-audio-control.json b/conf.d/project/config.d/onload-audio-control.json
index 1a45f99..7180bd5 100644
--- a/conf.d/project/config.d/onload-audio-control.json
+++ b/conf.d/project/config.d/onload-audio-control.json
@@ -8,7 +8,11 @@
"onload": [{
"label": "onload-default",
"info": "onload initialisation config",
- "plugin": "ctl-audio-plugin-sample.ctlso",
+ "plugin": {
+ "label" : "MyPlug",
+ "sharelib": "ctl-audio-plugin-sample.ctlso",
+ "lua2c": ["Lua2cHelloWorld1", "Lua2cHelloWorld2"]
+ },
"require": ["intel-hda", "jabra-usb", "scarlett-usb"],
"actions": [
{
diff --git a/conf.d/project/lua.d/onload-audio-controls.lua b/conf.d/project/lua.d/onload-audio-controls.lua
index b6fd811..4849632 100644
--- a/conf.d/project/lua.d/onload-audio-controls.lua
+++ b/conf.d/project/lua.d/onload-audio-controls.lua
@@ -21,37 +21,34 @@
function Audio_Init_CB (status, result, context)
print ("--inlua:Audio_Init_CB-- result=", Dump_Table(result))
print ("--inlua:Audio_Init_CB-- context=", Dump_Table(context))
-
-
- -- AFB:notice ("Audio_Init_Hal result='%s' context='%s'", result, context)
- -- AFB:debug ("Audio_Init_Hal result=%s context=%s", {["ret1"]=5678, ["ret2"]="abcd"}, context)
-
+
+ AFB:notice("Audio_Init_Hal_CB result='%s' context='%s'", result, context)
+
end
-- Function call at binding load time
function Audio_Init_Hal(args, query)
- local nextT = {
+ local nested = {
["next1"]=1234,
["next2"]="nested",
["next3"]=9999,
}
-
- local response = {
+ local context = {
["arg1"]=1234,
- ["arg2"]=nextT,
+ ["arg2"]=nested,
["arg3"]=5678,
}
- print ("--inlua:Audio_Init-- response=", Dump_Table(response))
-
- AFB:notice ("**** in-lua table='%s' ****", response)
+ print ("--inlua:Audio_Init-- response=", Dump_Table(responseT))
+ print("myplug=", Dump_Table(MyPlug));
- AFB:notice ("--LUA:Audio_Init_Hal args=%s query=%s", args, query);
+ -- This routine is defined in C sample plugin
+ local status=MyPlug:Lua2cHelloWorld1(nested)
-- query asynchronously loaded HAL
- AFB:service ('alsacore', 'hallist', {}, "Audio_Init_CB", {arg1=1234, arg2="toto"})
+ AFB:service ('alsacore', 'hallist', {}, "Audio_Init_CB", context)
end