aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alsa-afb/Alsa-SetGet.c12
-rw-r--r--conf.d/project/json.d/onload-aaaa-sample.json11
-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
-rw-r--r--nbproject/configurations.xml2
6 files changed, 69 insertions, 9 deletions
diff --git a/Alsa-afb/Alsa-SetGet.c b/Alsa-afb/Alsa-SetGet.c
index 71206e6..f70c5d6 100644
--- a/Alsa-afb/Alsa-SetGet.c
+++ b/Alsa-afb/Alsa-SetGet.c
@@ -76,12 +76,18 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl
case json_type_object:
// numid+values formated as {id:xxx, val:[aa,bb...,nn]}
- if (!json_object_object_get_ex(ctlRequest[idx].jToken, "id", &jId) || !json_object_object_get_ex(ctlRequest[idx].jToken, "val", &valuesJ)) {
- AFB_NOTICE("Invalid Json=%s missing 'id'|'val'", json_object_get_string(ctlRequest[idx].jToken));
+ if (!json_object_object_get_ex(ctlRequest[idx].jToken, "id", &jId)) {
+ AFB_NOTICE("Invalid Json=%s missing 'id'", json_object_get_string(ctlRequest[idx].jToken));
ctlRequest[idx].used = -1;
} else {
ctlRequest[idx].numId = json_object_get_int(jId);
- if (action == ACTION_SET) ctlRequest[idx].valuesJ = valuesJ;
+ if (action == ACTION_SET) {
+ if (!json_object_object_get_ex(ctlRequest[idx].jToken, "val", &valuesJ)) {
+ AFB_NOTICE("Invalid Json=%s missing 'val'", json_object_get_string(ctlRequest[idx].jToken));
+ ctlRequest[idx].used = -1;
+ } else
+ ctlRequest[idx].valuesJ = valuesJ;
+ }
}
break;
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
--- 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
+
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index d00c20b..9700858 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -1477,7 +1477,7 @@
<makefileType>
<makeTool>
<buildCommandWorkingDir>build</buildCommandWorkingDir>
- <buildCommand>${MAKE} -f Makefile</buildCommand>
+ <buildCommand>${MAKE} -f Makefile populate</buildCommand>
<cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
<executablePath>build/CMakeFiles/feature_tests.bin</executablePath>
<cTool flags="-g -fPIC -fPIC">