diff options
author | fulup <fulup.arfoll@iot.bzh> | 2018-06-06 11:47:08 +0200 |
---|---|---|
committer | fulup <fulup.arfoll@iot.bzh> | 2018-06-06 11:57:25 +0200 |
commit | 1594606d160d61153cf2396befdefdcf24a0b4eb (patch) | |
tree | 726645b48d3b0b3bc157ed6b1007bbc10f4e3791 | |
parent | 7aaf36d8e729400f7efc75d7e03e162e1f262293 (diff) |
Move smixer API create+attach into controller onload section
-rw-r--r-- | conf.d/project/etc/smixer-test-config.json | 20 | ||||
-rw-r--r-- | conf.d/project/htdocs/index.html | 22 | ||||
-rw-r--r-- | conf.d/project/lua.d/smixer-test-simple.lua | 12 | ||||
-rw-r--r-- | mixer-binding/mixer-binding.c | 30 | ||||
-rw-r--r-- | nbproject/configurations.xml | 253 | ||||
-rw-r--r-- | plugins/alsa/alsa-api-mixer.c | 80 |
6 files changed, 65 insertions, 352 deletions
diff --git a/conf.d/project/etc/smixer-test-config.json b/conf.d/project/etc/smixer-test-config.json index 3ed9f29..71eded8 100644 --- a/conf.d/project/etc/smixer-test-config.json +++ b/conf.d/project/etc/smixer-test-config.json @@ -12,24 +12,20 @@ "info": "Map alsa-loop subdevices to 4A HAL streams", "spath": "./package/lib/plugins:./package/var:./lib/plugins:./var", "libs": ["alsa-softmixer.ctlso", "smixer-test-simple.lua"], - "lua": { - "prefix": "smix", - "functions": ["_mixer_new_"] - } } ], "onload": [ { - "uid": "init-soft-mixer", - "info": "Initialise Audio Router", - "action": "lua://softmixer#_mixer_simple_test_" - } - ], - "controls": [ + "uid": "create-soft-mixer", + "info": "Create Audio Router", + "action": "plugin://softmixer#CreateMixer", + "args": {"uid":"Simple_Test_Mixer"} + }, { - "uid": "create", - "action": "plugin://softmixer#mixer_new" + "uid": "attach-soft-mixer", + "info": "Attach Stream to Audio Router", + "action": "lua://softmixer#_mixer_simple_test_" } ] } diff --git a/conf.d/project/htdocs/index.html b/conf.d/project/htdocs/index.html index df7ec80..c667dde 100644 --- a/conf.d/project/htdocs/index.html +++ b/conf.d/project/htdocs/index.html @@ -18,21 +18,21 @@ <h2>V3 API CALL</h2> <ol> - <li><button onclick="callbinder('MyMixer', 'info', {streams: true});">Streams List</button></li> - <li><button onclick="callbinder('MyMixer', 'info', {ramps: true});">Ramps List</button></li> - <li><button onclick="callbinder('MyMixer', 'info', {zones: true});">Zones List</button></li> + <li><button onclick="callbinder('smixer', 'info', {streams: true});">Streams List</button></li> + <li><button onclick="callbinder('smixer', 'info', {ramps: true});">Ramps List</button></li> + <li><button onclick="callbinder('smixer', 'info', {zones: true});">Zones List</button></li> <br> - <li><button onclick="callbinder('MyMixer', '8CH-USB/playback', {volume: '+10'});">Master 8CH-USB vol=+10</button></li> - <li><button onclick="callbinder('MyMixer', '8CH-USB/playback', {volume: '-10'});">Master 8CH-USB vol=-10</button></li> + <li><button onclick="callbinder('smixer', '8CH-USB/playback', {volume: '+10'});">Master 8CH-USB vol=+10</button></li> + <li><button onclick="callbinder('smixer', '8CH-USB/playback', {volume: '-10'});">Master 8CH-USB vol=-10</button></li> <br> - <li><button onclick="callbinder('MyMixer', 'multimedia', {toggle: true});">Stream Multimedia pause/resume</button></li> - <li><button onclick="callbinder('MyMixer', 'navigation', {toggle: true});">Stream Navigation pause/resume</button></li> + <li><button onclick="callbinder('smixer', 'multimedia', {toggle: true});">Stream Multimedia pause/resume</button></li> + <li><button onclick="callbinder('smixer', 'navigation', {toggle: true});">Stream Navigation pause/resume</button></li> <br> - <li><button onclick="callbinder('MyMixer', 'multimedia', {volume: '+10'});">Stream Multimedia volume=+10"</button></li> - <li><button onclick="callbinder('MyMixer', 'multimedia', {volume: '-10'});">Stream Multimedia volume=-10"</button></li> + <li><button onclick="callbinder('smixer', 'multimedia', {volume: '+10'});">Stream Multimedia volume=+10"</button></li> + <li><button onclick="callbinder('smixer', 'multimedia', {volume: '-10'});">Stream Multimedia volume=-10"</button></li> <br> - <li><button onclick="callbinder('MyMixer', 'multimedia', {ramp: {uid:'ramp-slow', volume:30}});">Stream Multimedia ramp-slow=30"</button></li> - <li><button onclick="callbinder('MyMixer', 'multimedia', {ramp: {uid:'ramp-fast', volume:80}});">Stream Multimedia ramp-fast=80"</button></li> + <li><button onclick="callbinder('smixer', 'multimedia', {ramp: {uid:'ramp-slow', volume:30}});">Stream Multimedia ramp-slow=30"</button></li> + <li><button onclick="callbinder('smixer', 'multimedia', {ramp: {uid:'ramp-fast', volume:80}});">Stream Multimedia ramp-fast=80"</button></li> </ol> <div id="main" style="visibility:hidden"> diff --git a/conf.d/project/lua.d/smixer-test-simple.lua b/conf.d/project/lua.d/smixer-test-simple.lua index 3a5dc98..99893c1 100644 --- a/conf.d/project/lua.d/smixer-test-simple.lua +++ b/conf.d/project/lua.d/smixer-test-simple.lua @@ -37,7 +37,6 @@ end function _mixer_simple_test_ (source, args) do - -- Mixer UID is used as API name -- ==================== Default rate =========================== @@ -220,16 +219,9 @@ function _mixer_simple_test_ (source, args) } - -- direct LUA call because controller cannot call its own API from AFB:servsync - error,result= smix:_mixer_new_ (source, {["uid"]="MyMixer"}) - if (error ~= 0) then - AFB:error (source, "--InLua-- smix:_mixer_new_ fail config=%s", Dump_Table(result)) - goto OnErrorExit - else - AFB:notice (source, "--InLua-- smix:_mixer_new_ done\n") - end - error,result= AFB:servsync(source, "MyMixer", "attach", MyTestHal) + + error,result= AFB:servsync(source, "smixer", "attach", MyTestHal) if (error) then AFB:error (source, "--InLua-- API MyMixer/attach fail error=%d", error) goto OnErrorExit diff --git a/mixer-binding/mixer-binding.c b/mixer-binding/mixer-binding.c index edfb408..ab61baa 100644 --- a/mixer-binding/mixer-binding.c +++ b/mixer-binding/mixer-binding.c @@ -30,7 +30,7 @@ PUBLIC afb_dynapi *AFB_default; static CtlSectionT ctrlSections[]= { {.key="resources" , .loadCB= PluginConfig}, {.key="onload" , .loadCB= OnloadConfig}, - {.key="controls", .loadCB= ControlConfig}, + // {.key="controls", .loadCB= ControlConfig}, {.key=NULL} }; @@ -62,18 +62,6 @@ STATIC int CtrlLoadStaticVerbs (afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { return errcount; }; - -STATIC int CtrlInitOneApi (AFB_ApiT apiHandle) { - - AFB_default = apiHandle; // hugely hack to make all V2 AFB_DEBUG to work in fileutils - - // retrieve section config from api handle - CtlConfigT *ctrlConfig = (CtlConfigT*) afb_dynapi_get_userdata(apiHandle); - int err = CtlConfigExec (apiHandle, ctrlConfig); - - return err; -} - // next generation dynamic API-V3 mode #include <signal.h> @@ -85,24 +73,21 @@ STATIC int CtrlLoadOneApi (void *cbdata, AFB_ApiT apiHandle) { afb_dynapi_set_userdata(apiHandle, ctrlConfig); // add static controls verbs - int err = CtrlLoadStaticVerbs (apiHandle, CtrlApiVerbs); - if (err) { + int error = CtrlLoadStaticVerbs (apiHandle, CtrlApiVerbs); + if (error) { AFB_ApiError(apiHandle, "CtrlLoadSection fail to Registry static V2 verbs"); goto OnErrorExit; } // load section for corresponding API - err= CtlLoadSections(apiHandle, ctrlConfig, ctrlSections); + error= CtlLoadSections(apiHandle, ctrlConfig, ctrlSections); // declare an event event manager for this API; afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent); - // init API function (does not receive user closure ??? - afb_dynapi_on_init(apiHandle, CtrlInitOneApi); - // should not seal API as each mixer+stream create a new verb // afb_dynapi_seal(apiHandle); - return err; + return error; OnErrorExit: return 1; @@ -130,7 +115,6 @@ PUBLIC int afbBindingVdyn(afb_dynapi *apiHandle) { goto OnErrorExit; } - if (!ctrlConfig->api) { AFB_ApiError(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath); goto OnErrorExit; @@ -140,6 +124,10 @@ PUBLIC int afbBindingVdyn(afb_dynapi *apiHandle) { // create one API per config file (Pre-V3 return code ToBeChanged) int status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig); + // config exec should be done after api init in order to enable onload to use newly defined ctl API. + if (!status) + status = CtlConfigExec (apiHandle, ctrlConfig); + return status; OnErrorExit: diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index e0e102a..d60d750 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -174,6 +174,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -186,6 +188,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -198,10 +202,21 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> </incDir> + <preprocessorList> + <Elem>AFB_BINDING_VERSION=dyn</Elem> + <Elem>CONTROL_CONFIG_PATH="/home/fulup/opt/4a-softmixer/etc:/home/fulup/Workspace/Audio-4a/4a-softmixer/build/package/etc"</Elem> + <Elem>CONTROL_LUA_PATH="/home/fulup/Workspace/Audio-4a/4a-softmixer/conf.d/project/lua.d:/home/fulup/opt/4a-softmixer/data"</Elem> + <Elem>CONTROL_PLUGIN_PATH="/home/fulup/opt/4a-softmixer/lib/plugins:/home/fulup/Workspace/Audio-4a/4a-softmixer/build/package/lib/plugins"</Elem> + <Elem>CONTROL_SUPPORT_LUA</Elem> + <Elem>CTL_PLUGIN_MAGIC=987456123</Elem> + <Elem>USE_API_DYN=1</Elem> + </preprocessorList> </cTool> </item> <item path="app-controller-submodule/ctl-lib/ctl-event.c" @@ -210,6 +225,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -222,6 +239,7 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> </incDir> </cTool> @@ -232,6 +250,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -244,6 +264,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -256,6 +278,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -268,6 +292,8 @@ flavor2="3"> <cTool flags="1"> <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> <pElem>app-afb-helpers-submodule</pElem> <pElem>../../../opt/include</pElem> <pElem>build/app-controller-submodule/ctl-lib</pElem> @@ -337,18 +363,6 @@ <item path="plugins/alsa/alsa-api-loop.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -359,16 +373,7 @@ <item path="plugins/alsa/alsa-api-mixer.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> </incDir> <preprocessorList> <Elem>alsa_softmixer_EXPORTS</Elem> @@ -378,18 +383,6 @@ <item path="plugins/alsa/alsa-api-pcm.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -400,18 +393,6 @@ <item path="plugins/alsa/alsa-api-ramp.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -422,18 +403,6 @@ <item path="plugins/alsa/alsa-api-sink.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -444,18 +413,6 @@ <item path="plugins/alsa/alsa-api-source.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -466,18 +423,6 @@ <item path="plugins/alsa/alsa-api-streams.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -488,18 +433,6 @@ <item path="plugins/alsa/alsa-api-zones.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -509,20 +442,6 @@ </item> <item path="plugins/alsa/alsa-capture.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> - <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> - </incDir> <preprocessorList> <Elem>CONTROL_CONFIG_PATH="/home/fulup/opt/4a-softmixer/etc:/home/fulup/Workspace/Audio-4a/4a-softmixer/build/package/etc"</Elem> <Elem>CONTROL_LUA_PATH="/home/fulup/opt/4a-softmixer/data:/home/fulup/Workspace/Audio-4a/4a-softmixer/conf.d/project/lua.d"</Elem> @@ -535,18 +454,6 @@ <item path="plugins/alsa/alsa-core-ctl.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -557,18 +464,6 @@ <item path="plugins/alsa/alsa-core-pcm.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -579,18 +474,6 @@ <item path="plugins/alsa/alsa-effect-ramp.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -601,18 +484,6 @@ <item path="plugins/alsa/alsa-plug-dmix.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -623,18 +494,6 @@ <item path="plugins/alsa/alsa-plug-rate.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -645,18 +504,6 @@ <item path="plugins/alsa/alsa-plug-route.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -667,18 +514,6 @@ <item path="plugins/alsa/alsa-plug-vol.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -689,18 +524,6 @@ <item path="plugins/alsa/alsa-softmixer.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -711,18 +534,6 @@ <item path="plugins/alsa/alsa-utils-bypath.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> @@ -733,18 +544,6 @@ <item path="plugins/alsa/alsa-utils-dump.c" ex="false" tool="0" flavor2="2"> <cTool flags="0"> <incDir> - <pElem>app-controller-submodule/ctl-lib</pElem> - <pElem>build/app-controller-submodule/ctl-lib</pElem> - <pElem>/usr/include</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>/usr/include/alsa</pElem> - <pElem>../../../opt/include</pElem> - <pElem>/usr/include/p11-kit-1</pElem> - <pElem>/usr/include/uuid</pElem> - <pElem>../../../opt/include/alsa</pElem> - <pElem>mixer-binding</pElem> - <pElem>app-afb-helpers-submodule</pElem> - <pElem>build/plugins/alsa</pElem> <pElem>/usr/include/lua5.3</pElem> </incDir> <preprocessorList> diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c index 112adbb..8616384 100644 --- a/plugins/alsa/alsa-api-mixer.c +++ b/plugins/alsa/alsa-api-mixer.c @@ -278,13 +278,6 @@ STATIC void MixerPingVerb(AFB_ReqT request) { return; } -STATIC void MixerEventCB(AFB_ApiT api, const char *evtLabel, struct json_object *eventJ) { - - SoftMixerT *mixer = (SoftMixerT*) afb_dynapi_get_userdata(api); - assert(mixer); - - AFB_ApiNotice(api, "Mixer=%s Received event=%s, eventJ=%s", mixer->uid, evtLabel, json_object_get_string(eventJ)); -} // Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT STATIC AFB_ApiVerbs CtrlApiVerbs[] = { @@ -306,38 +299,7 @@ STATIC int LoadStaticVerbs(SoftMixerT *mixer, AFB_ApiVerbs *verbs) { return errcount; }; -STATIC int MixerInitCB(AFB_ApiT api) { - - SoftMixerT *mixer = (SoftMixerT*) afb_dynapi_get_userdata(api); - assert(mixer); - - // attach AFB mainloop to mixer - mixer->sdLoop = AFB_GetEventLoop(api); - - - AFB_ApiNotice(api, "MixerInitCB API=%s activated info=%s", mixer->uid, mixer->info); - - return 0; -} - -STATIC int MixerApiCB(void* handle, AFB_ApiT api) { - SoftMixerT *mixer = (SoftMixerT*) handle; - - mixer->api = api; - afb_dynapi_set_userdata(api, mixer); - afb_dynapi_on_event(api, MixerEventCB); - afb_dynapi_on_init(api, MixerInitCB); - - int error = LoadStaticVerbs(mixer, CtrlApiVerbs); - if (error) goto OnErrorExit; - - return 0; - -OnErrorExit: - return -1; -} - -CTLP_LUA2C(_mixer_new_, source, argsJ, responseJ) { +CTLP_CAPI(CreateMixer, source, argsJ, responseJ) { SoftMixerT *mixer = calloc(1, sizeof (SoftMixerT)); int error; mixer->max.loops = SMIXER_DEFLT_RAMPS; @@ -377,40 +339,16 @@ CTLP_LUA2C(_mixer_new_, source, argsJ, responseJ) { mixer->zones = calloc(mixer->max.zones + 1, sizeof (void*)); mixer->streams = calloc(mixer->max.streams + 1, sizeof (void*)); mixer->ramps = calloc(mixer->max.ramps + 1, sizeof (void*)); + + mixer->sdLoop = AFB_GetEventLoop(source->api); + mixer->api= source->api; + afb_dynapi_set_userdata(source->api, mixer); - // create mixer verb within API. - error = afb_dynapi_new_api(source->api, mixer->uid, mixer->info, !MAINLOOP_CONCURENCY, MixerApiCB, mixer); - if (error) { - AFB_ApiError(source->api, "_mixer_new_ mixer=%s fail to Registry API verb", mixer->uid); - goto OnErrorExit; - } - + error = LoadStaticVerbs(mixer, CtrlApiVerbs); + if (error) goto OnErrorExit; + return 0; OnErrorExit: return -1; -} - -// provide a similar command but for API - -CTLP_CAPI(mixer_new, source, argsJ, queryJ) { - json_object * responseJ; - - // merge static config args with dynamic one coming from the request - if (argsJ && json_object_get_type(argsJ) == json_type_object) { - - json_object_object_foreach(argsJ, key, val) { - json_object_get(val); - json_object_object_add(queryJ, key, val); - } - } - - int error = _mixer_new_(source, queryJ, &responseJ); - - if (error) - AFB_ReqFailF(source->request, "fail-create", "invalid arguments"); - else - AFB_ReqSucess(source->request, responseJ, NULL); - - return error; -} +}
\ No newline at end of file |