From e8b7ffa70194d1cc3ef4cc52bb0ace9f133514cf Mon Sep 17 00:00:00 2001 From: fulup Date: Tue, 15 Aug 2017 12:48:59 +0200 Subject: docall working with simple table --- Controler-afb/ctl-binding.c | 3 +- Controler-afb/ctl-dispatch.c | 20 +- Controler-afb/ctl-lua.c | 67 ++-- conf.d/cmake/config.cmake | 5 +- conf.d/project/lua.d/CMakeLists.txt | 8 +- conf.d/project/lua.d/onload-audio-controls.lua | 11 +- conf.d/project/lua.d/onload-audio-oncall.lua | 43 ++- htdocs/audio-control.html | 6 +- nbproject/configurations.xml | 431 +++++++++++++++++++++++++ nbproject/project.xml | 4 + 10 files changed, 526 insertions(+), 72 deletions(-) diff --git a/Controler-afb/ctl-binding.c b/Controler-afb/ctl-binding.c index 19f97eb..554199b 100644 --- a/Controler-afb/ctl-binding.c +++ b/Controler-afb/ctl-binding.c @@ -69,7 +69,8 @@ PUBLIC int CtlBindingInit () { errcount += LuaLibInit(); // now that everything is initialised execute the onload action - errcount += DispatchOneOnLoad(CONTROL_ONLOAD_DEFAULT); + if (!errcount) + errcount += DispatchOneOnLoad(CONTROL_ONLOAD_DEFAULT); AFB_DEBUG ("Audio Policy Control Binding Done errcount=%d", errcount); return errcount; diff --git a/Controler-afb/ctl-dispatch.c b/Controler-afb/ctl-dispatch.c index 7d6a31d..3318c8d 100644 --- a/Controler-afb/ctl-dispatch.c +++ b/Controler-afb/ctl-dispatch.c @@ -90,7 +90,7 @@ STATIC int DispatchOneControl (DispatchHandleT **controls, const char* controlLa json_object_get( actions[idx].argsJ); // make sure afb_service_call does not free the argsJ int err = afb_service_call_sync(actions[idx].api, actions[idx].call, actions[idx].argsJ, &returnJ); if (err) { - static const char*format="DispatchOneControl Api api=%s verb=%s args=%s"; + static const char*format="DispatchOneControl(Api) api=%s verb=%s args=%s"; if (afb_req_is_valid(request))afb_req_fail_f(request, "DISPATCH-CTL-MODE:API", format, actions[idx].label, actions[idx].api, actions[idx].call); else AFB_ERROR (format, actions[idx].api, actions[idx].call, actions[idx].label); goto OnErrorExit; @@ -101,9 +101,9 @@ STATIC int DispatchOneControl (DispatchHandleT **controls, const char* controlLa case CTL_MODE_LUA: err= LuaCallFunc (&actions[idx], queryJ); if (err) { - static const char*format= "DispatchOneControl func=%s args=%s"; - if (afb_req_is_valid(request)) afb_req_fail_f(request, "DISPATCH-CTL-MODE:Lua", format, actions[idx].call, json_object_get_string(actions[idx].argsJ)); - else AFB_ERROR (format, actions[idx].call, json_object_get_string(actions[idx].argsJ)); + static const char*format= "DispatchOneControl(Lua) label=%s func=%s args=%s"; + if (afb_req_is_valid(request)) afb_req_fail_f(request, "DISPATCH-CTL-MODE:Lua", format, actions[idx].label, actions[idx].call, json_object_get_string(actions[idx].argsJ)); + else AFB_ERROR (format, actions[idx].label, actions[idx].call, json_object_get_string(actions[idx].argsJ)); goto OnErrorExit; } break; @@ -111,17 +111,17 @@ STATIC int DispatchOneControl (DispatchHandleT **controls, const char* controlLa case CTL_MODE_CB: err= (*actions[idx].actionCB) (&actions[idx], queryJ, configHandle->context); if (err) { - static const char*format="DispatchOneControl func=%s args=%s"; - if (afb_req_is_valid(request)) afb_req_fail_f(request, "DISPATCH-CTL-MODE:Cb", format, actions[idx].call, json_object_get_string(actions[idx].argsJ)); - else AFB_ERROR (format, actions[idx].call, json_object_get_string(actions[idx].argsJ)); + static const char*format="DispatchOneControl(Callback) label%s func=%s args=%s"; + if (afb_req_is_valid(request)) afb_req_fail_f(request, "DISPATCH-CTL-MODE:Cb", format, actions[idx].label, actions[idx].call, json_object_get_string(actions[idx].argsJ)); + else AFB_ERROR (format, actions[idx].label, actions[idx].call, json_object_get_string(actions[idx].argsJ)); goto OnErrorExit; } break; default:{ - static const char*format="DispatchOneControl unknown mode control=%s action=%s"; - AFB_ERROR (format, controls[index]->label, actions[idx].label); - if (afb_req_is_valid(request))afb_req_fail_f(request, "DISPATCH-CTL-MODE:Unknown", format, controls[index]->label, actions[idx].label); + static const char*format="DispatchOneControl(unknown) mode control=%s action=%s"; + AFB_ERROR (format, controls[index]->label); + if (afb_req_is_valid(request))afb_req_fail_f(request, "DISPATCH-CTL-MODE:Unknown", format, controls[index]->label); } } } diff --git a/Controler-afb/ctl-lua.c b/Controler-afb/ctl-lua.c index 275b9d3..a7cd52f 100644 --- a/Controler-afb/ctl-lua.c +++ b/Controler-afb/ctl-lua.c @@ -238,6 +238,9 @@ STATIC void LuaFormatMessage(lua_State* luaState, LuaAfbMessageT action) { message="-- Empty Message ???"; goto PrintMessage; } + + //AFB_NOTICE("**** responseJ=%s", json_object_get_string(responseJ)); + // if we have only on argument just return the value. if (json_object_get_type(responseJ)!=json_type_array || json_object_array_length(responseJ) <2) { @@ -256,22 +259,31 @@ STATIC void LuaFormatMessage(lua_State* luaState, LuaAfbMessageT action) { if (format[idx]=='%' && format[idx] !='\0') { json_object *slotJ= json_object_array_get_idx(responseJ, arrayIdx); + //if (slotJ) AFB_NOTICE("**** idx=%d slotJ=%s", arrayIdx, json_object_get_string(slotJ)); + switch (format[++idx]) { case 'd': if (slotJ) targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"%d", json_object_get_int(slotJ)); else targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"nil"); + arrayIdx++; break; case 'f': if (slotJ) targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"%f", json_object_get_double(slotJ)); else targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"nil"); + arrayIdx++; + break; + + case'%': + targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"%"); break; case 's': default: if (slotJ) targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"%s", json_object_get_string(slotJ)); else targetIdx += snprintf (&message[targetIdx], LUA_MSG_MAX_LENGTH-targetIdx,"nil"); - } + arrayIdx++; + } } else { message[targetIdx++] = format[idx]; @@ -497,7 +509,7 @@ STATIC int LuaAfbPushEvent(lua_State* luaState) { // Generated some fake event based on watchdog/counter PUBLIC int LuaCallFunc (DispatchActionT *action, json_object *queryJ) { - int err, count=0; + int err, count; json_object* argsJ = action->argsJ; const char* func = action->call; @@ -506,29 +518,22 @@ PUBLIC int LuaCallFunc (DispatchActionT *action, json_object *queryJ) { lua_getglobal(luaState, func); // push argsJ on the stack + count=0; if (!argsJ) { lua_pushnil(luaState); count++; - } else if (json_object_get_type(argsJ) != json_type_array) { + } else { count+= LuaPushArgument (argsJ); - } else { - for (int idx=0; idx

  • -
  • -
  • -
  • +
  • +
  • +
  • diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 6ac0844..62a0f3d 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -1231,5 +1231,436 @@ + + + GNU|GNU + false + false + + + + + + + + + + true + + + + build + ${MAKE} -f Makefile install + ${MAKE} -f Makefile clean + build/CMakeFiles/feature_tests.bin + + + ../../../opt/include + ../../../opt/include/alsa + /usr/include/p11-kit-1 + /usr/include/json-c + /usr/include/lua5.3 + + + CONTROL_CONFIG_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/conf.d/project/config.d:/usr/local/controler/config.d" + CONTROL_CONFIG_POST="control" + CONTROL_CONFIG_PRE="onload" + CONTROL_LUA_EVENT="luaevt" + CONTROL_LUA_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/conf.d/project/lua.d:/usr/local/controler/ctl-lua.d" + CONTROL_MAXPATH_LEN=255 + CONTROL_ONLOAD_DEFAULT="onload-default" + CONTROL_PLUGIN_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build:/home/fulup/opt/audio-bindings/ctlplug:/usr/lib/afb/ctlplug" + CTL_PLUGIN_MAGIC=2468013579 + MAX_LINEAR_DB_SCALE=24 + MAX_SND_CARD=16 + TLV_BYTE_SIZE=256 + + + + + build + cmake .. + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Audio-Common + build/Controler-afb + + + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + + + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + + + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + + + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + + + control_afb_EXPORTS + + + + + + + build/Controler-afb + + + audio_plugin_sample_EXPORTS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shared-Interface + HAL-afb/HAL-interface + build/HAL-afb/Unicens-USB + + + + + + + HAL-afb/HAL-interface + build/HAL-afb/Unicens-USB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + build/Alsa-Plugin/Alsa-Policy-Hook + + + CONTROL_DOSCRIPT_PRE="doscript" + PIC + policy_hook_cb_EXPORTS + + + + + + + Audio-Common + build/Alsa-afb + + + CONTROL_DOSCRIPT_PRE="doscript" + alsa_lowlevel_EXPORTS + + + + + + + Audio-Common + build/Audio-Common + + + CONTROL_DOSCRIPT_PRE="doscript" + + + + + + + Audio-Common + build/Controler-afb + build/HAL-afb/HAL-plugin + /usr/include/alsa + build/Common + + + CONTROL_CDEV_RX="/dev/inic-usb-crx" + CONTROL_CDEV_TX="/dev/inic-usb-ctx" + audio_plugin_sample_EXPORTS + control_afb_EXPORTS + + + + + + + CONTROL_DOSCRIPT_PRE="doscript" + + + + + + + HAL-afb/HAL-interface + Audio-Common + build/HAL-afb/HAL-interface + + + CONTROL_DOSCRIPT_PRE="doscript" + + + + + + + Audio-Common + build/Controler-afb + build/HAL-afb/HAL-plugin + ../../../opt/include/afb + HAL-afb/HAL-plugin + + + CONTROL_CDEV_RX="/dev/inic-usb-crx" + CONTROL_CDEV_TX="/dev/inic-usb-ctx" + audio_plugin_sample_EXPORTS + control_afb_EXPORTS + + + + + + + HAL-afb/HAL-interface + Audio-Common + build/HAL-afb/HDA-intel + + + CONTROL_DOSCRIPT_PRE="doscript" + hal_intel_hda_EXPORTS + + + + + + + HAL-afb/HAL-interface + Audio-Common + build/HAL-afb/Jabra-Solemate + + + CONTROL_DOSCRIPT_PRE="doscript" + hal_jabra_usb_EXPORTS + + + + + + + HAL-afb/HAL-interface + Audio-Common + build/HAL-afb/Scarlett-Focusrite + + + CONTROL_DOSCRIPT_PRE="doscript" + hal_scalett_usb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + build/HAL-afb/HAL-plugin + ../../../opt/include/afb + HAL-afb/Unicens-USB + + + CONTROL_CDEV_RX="/dev/inic-usb-crx" + CONTROL_CDEV_TX="/dev/inic-usb-ctx" + audio_plugin_sample_EXPORTS + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + build/HAL-afb/HAL-plugin + ../../../opt/include/afb + HighLevel-afb + Shared-Interface + build/HighLevel-afb + + + audio_plugin_sample_EXPORTS + control_afb_EXPORTS + + + + + + + Audio-Common + build/Controler-afb + build/HAL-afb/HAL-plugin + + + audio_plugin_sample_EXPORTS + control_afb_EXPORTS + + + + diff --git a/nbproject/project.xml b/nbproject/project.xml index 988f845..5f13ad6 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -25,6 +25,10 @@ Aplay_Multimedia 0 + + LocalHostNoTrace + 0 + false -- cgit 1.2.3-korg