diff options
author | Tai Vuong <tvuong@audiokinetic.com> | 2017-11-03 18:55:54 -0400 |
---|---|---|
committer | Tai Vuong <tvuong@audiokinetic.com> | 2017-11-03 18:55:54 -0400 |
commit | 68f1187061c28ecf6439b4dd465f4d256529dc55 (patch) | |
tree | 5c86b5c00cda5d183a7dce47622a294a1b9179cb /ahl-binding/ahl-binding.c | |
parent | b929cdf5d0b27915e84e174c81ffd7e2b2f1beda (diff) |
various bug fix, add alsa configuration file to match with Hal control
Diffstat (limited to 'ahl-binding/ahl-binding.c')
-rw-r--r-- | ahl-binding/ahl-binding.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ahl-binding/ahl-binding.c b/ahl-binding/ahl-binding.c index c205c8e..0b2348a 100644 --- a/ahl-binding/ahl-binding.c +++ b/ahl-binding/ahl-binding.c @@ -867,12 +867,19 @@ PUBLIC void audiohlapi_volume(struct afb_req req) json_object *paramJ= json_object_new_string(volumeStr); json_object_object_add(pPolicyEndpointJ, "arg_volume", paramJ); - int policyAllowed = Policy_SetVolume(pPolicyEndpointJ); + json_object * pPolicyVolumeReply = NULL; + int policyAllowed = Policy_SetVolume(pPolicyEndpointJ,&pPolicyVolumeReply); if (!policyAllowed) { afb_req_fail(req, "Audio policy violation", "Set volume not allowed in current context"); return; } + + err = wrap_json_unpack(pPolicyVolumeReply,"{s:i}","volume",&pEndpointInfo->iVolume); + if (err) { + afb_req_fail_f(req, "Invalid policy reply", "Policy volume change reply not a valid json object=%s", json_object_get_string(pPolicyVolumeReply)); + return; + } #else // Simulate that policy returns target state (accepted) pEndpointInfo->iVolume = atoi(volumeStr); @@ -951,15 +958,28 @@ PUBLIC void audiohlapi_property(struct afb_req req) json_object_object_add(pPolicyEndpointJ, "arg_property_value", propValueJ); // Call policy to allow custom policy actions in current context - int policyAllowed = Policy_SetProperty(pPolicyEndpointJ); + json_object * pPropertyReply = NULL; + int policyAllowed = Policy_SetProperty(pPolicyEndpointJ,&pPropertyReply); if (!policyAllowed) { afb_req_fail(req, "Audio policy violation", "Set endpoint property not allowed in current context"); return; } + + json_object * pPropReplyValue = NULL; + err = wrap_json_unpack(pPropertyReply,"{s:o}","value",&pPropReplyValue); + if (err) { + afb_req_fail_f(req, "Invalid policy reply", "Policy property change reply not a valid json object=%s", json_object_get_string(pPropertyReply)); + return; + } + if (pEndpointInfo->pPropTable && pPropReplyValue) { + json_object_get(pPropReplyValue); + g_hash_table_insert(pEndpointInfo->pPropTable, propertyName, pPropReplyValue); + } #else // Simulate that policy returns target state (accepted) - if (pEndpointInfo->pPropTable) + if (pEndpointInfo->pPropTable && propValueJ) + json_object_get(propValueJ); g_hash_table_insert(pEndpointInfo->pPropTable, propertyName, propValueJ); #endif } |