From 6cc7b3b79beab5d1f0a6a1cd23d565803b3c9b52 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Thu, 14 Jun 2018 11:04:43 +0200 Subject: Add special permission to the mixer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mixer will make use of the high level api to control volume, but it has to have special permission to be allowed to control volume without opening the stream. Change-Id: Iabf76e3df329de3706f24ef21b6df35b5f5aab60 Signed-off-by: Loïc Collignon --- ahl-binding/role.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ahl-binding/role.cpp b/ahl-binding/role.cpp index b6a9c1f..2be3dc5 100644 --- a/ahl-binding/role.cpp +++ b/ahl-binding/role.cpp @@ -229,16 +229,23 @@ void role_t::close(afb_request* r, json_object* o) void role_t::volume(afb_request* r, json_object* o) { - if (!opened_) + if(!afb_request_has_permission(r, "urn:AGL:permission::public:4a-audio-mixer")) { - afb_request_fail(r, "You have to open the stream first!", nullptr); - return; - } + if (!opened_) + { + afb_request_fail(r, "You have to open the stream first!", nullptr); + return; + } - if(!afb_request_context_get(r)) + if(!afb_request_context_get(r)) + { + afb_request_fail(r, "Stream is opened by another client!", nullptr); + return; + } + } + else { - afb_request_fail(r, "Stream is opened by another client!", nullptr); - return; + AFB_DYNAPI_NOTICE(ahl_binding_t::instance().handle(), "Granted special audio-mixer permission to change volume"); } json_object* value = json_object_object_get(o, "value"); @@ -249,7 +256,7 @@ void role_t::volume(afb_request* r, json_object* o) } json_object_get(value); - + json_object* a = json_object_new_object(); json_object_object_add(a, "volume", value); @@ -262,7 +269,7 @@ void role_t::volume(afb_request* r, json_object* o) { AFB_DYNAPI_DEBUG(handle, "Got the following answer: %s", json_object_to_json_string(result)); afb_request* r = (afb_request*)closure; - + json_object_get(result); if (status) afb_request_fail(r, json_object_to_json_string(result), nullptr); else afb_request_success(r, result, nullptr); -- cgit 1.2.3-korg