aboutsummaryrefslogtreecommitdiffstats
path: root/conf.d/project/lua.d
diff options
context:
space:
mode:
Diffstat (limited to 'conf.d/project/lua.d')
-rw-r--r--conf.d/project/lua.d/README.md9
-rw-r--r--conf.d/project/lua.d/netbeans-aaaa-run-config.pngbin163727 -> 145969 bytes
-rw-r--r--conf.d/project/lua.d/onload-aaaa-03-controls.lua44
3 files changed, 48 insertions, 5 deletions
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
--- a/conf.d/project/lua.d/netbeans-aaaa-run-config.png
+++ b/conf.d/project/lua.d/netbeans-aaaa-run-config.png
Binary files 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
+