From 1dd19ac494da7b223bc919a85c0e6c16502e9a77 Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Sun, 27 Aug 2017 18:09:54 +0200 Subject: Fix Alsacore ctlget in form ctl={id:xxx} --- conf.d/project/json.d/onload-aaaa-sample.json | 11 ++++++ conf.d/project/lua.d/README.md | 9 +++-- conf.d/project/lua.d/netbeans-aaaa-run-config.png | Bin 163727 -> 145969 bytes conf.d/project/lua.d/onload-aaaa-03-controls.lua | 44 +++++++++++++++++++++- 4 files changed, 59 insertions(+), 5 deletions(-) (limited to 'conf.d/project') diff --git a/conf.d/project/json.d/onload-aaaa-sample.json b/conf.d/project/json.d/onload-aaaa-sample.json index c95a62f..8f05317 100644 --- a/conf.d/project/json.d/onload-aaaa-sample.json +++ b/conf.d/project/json.d/onload-aaaa-sample.json @@ -22,6 +22,17 @@ "controls": [ { + "label": "Volume", + "permissions": "urn:AGL:permission:audio:public:multimedia", + "actions": { + "label": "adjust-master-volume", + "info" : "volume value should be provided by requesting client", + "lua": "_Permament_Control", + "args": { + "ctl" : "Master_Playback_Volume" + } + } + },{ "label": "Multimedia", "permissions": "urn:AGL:permission:audio:public:multimedia", "actions": { diff --git a/conf.d/project/lua.d/README.md b/conf.d/project/lua.d/README.md index 86b60dd..fc3548b 100644 --- a/conf.d/project/lua.d/README.md +++ b/conf.d/project/lua.d/README.md @@ -12,10 +12,11 @@ export BUILD_DIR=build # with an internal MPDC (Pusic Player Daemon Client) API afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ --alias=/monitoring:$HOME/opt/afb-monitoring \ ---ldpaths=. \ +--ldpaths=package/lib \ --alias=/monitoring:/home/fulup/opt/afb-monitoring \ --binding=../../afb-controller/$BUILD_DIR/package/lib/afb-controller.so \ ---binding=../../afb-mpdc/$BUILD_DIR/package/lib/afb-mpdc-api.so +--binding=../../afb-mpdc/$BUILD_DIR/package/lib/afb-mpdc-api.so \ +--ws-server=unix:/var/tmp/afb-ws/mpdc # with an exernal MPDC API afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ @@ -28,6 +29,8 @@ afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ # Note: - Both sample make the assumption the monitoring HTML5 app is avaliable at $HOME/opt/afb-monitoring - With second sample you should obviously have your MPDC service exposing its API with --ws-server=unix:/var/tmp/afb-ws/mpdc - - Running AAAA from Netbeans ![Sample config](netbeans-aaaa-run-config.png) + - Should use 'make populate' to get ./build/package/lib to be uptodate ``` + +Running AAAA from you IDE ![Sample config](netbeans-aaaa-run-config.png) diff --git a/conf.d/project/lua.d/netbeans-aaaa-run-config.png b/conf.d/project/lua.d/netbeans-aaaa-run-config.png index 7091a42..ffb0e5d 100644 Binary files a/conf.d/project/lua.d/netbeans-aaaa-run-config.png and b/conf.d/project/lua.d/netbeans-aaaa-run-config.png differ diff --git a/conf.d/project/lua.d/onload-aaaa-03-controls.lua b/conf.d/project/lua.d/onload-aaaa-03-controls.lua index 6c7c8a5..ae1269b 100644 --- a/conf.d/project/lua.d/onload-aaaa-03-controls.lua +++ b/conf.d/project/lua.d/onload-aaaa-03-controls.lua @@ -26,6 +26,12 @@ _CurrentHalVolume={} + +--[[ Apply control + * source=1 permanent change requested + * source=0 temporally request control + * source=-1 temporally release control +-- ------------------------------------ --]] local function Apply_Hal_Control(source, label, adjustment) local HAL = _Global_Context["registry"] @@ -41,7 +47,8 @@ local function Apply_Hal_Control(source, label, adjustment) -- action set loop on active HAL and get current volume -- if label respond then do volume adjustment - if (source == 0) then + + if (source >= 0) then -- get current volume for each HAL local err,result= AFB:servsync(hal["api"],"ctlget", {["label"]=label}) @@ -84,7 +91,7 @@ local function Apply_Hal_Control(source, label, adjustment) end --- Simple Happy(granted) Control +-- Temporally adjust volume function _Temporarily_Control(source, control, client) printf ("[--> _Temporarily_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) @@ -116,3 +123,36 @@ function _Temporarily_Control(source, control, client) return 0 -- happy return end + +-- Permanent Adjust volume +function _Permanent_Control(source, control, client) + + printf ("[--> _Permanent_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) + + -- Init should have been properly done + if (_Global_Context["registry"] == nil) then + AFB:error ("--* (Hoops) No Hal in _Global_Context=%s", Dump_Table(_Global_Context)) + return 1 + end + + -- make sure label as valid + if (control["ctl"] == nil or control["val"] == nil) then + AFB:error ("--* Action Ignore no/invalid control=%s", Dump_Table(control)) + return 1 -- unhappy + end + + if (source == 0) then + AFB:info("-- Adjust %s=%d", control["ctl"], control["val"]) + local error=Apply_Hal_Control(1, control["ctl"], control["val"]) + if (error == nil) then + return 1 -- unhappy + end + AFB:notice ("[<-- _Permanent_Control Granted<--]") + else + Apply_Hal_Control(source, control["ctl"],0) + AFB:notice ("[<-- _Permanent_Control Restore--]") + end + + return 0 -- happy return +end + -- cgit 1.2.3-korg