From 22c2633ac833ae78ff84beafce19cec0f05758a2 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Tue, 12 Jun 2018 11:00:25 +0200 Subject: Update to last softmixer and hal, plus some fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the last 4a-softmixer and 4a-hal-generic versions. Fix some potential crash and performance bottleneck. Now support sessions to disallow multiple opening or closing by not owner. Change-Id: I95b020a3fab03b1e1058812adae1d8d5986f282b Signed-off-by: Loïc Collignon --- ahl-binding/ahl-binding.hpp | 52 +++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'ahl-binding/ahl-binding.hpp') diff --git a/ahl-binding/ahl-binding.hpp b/ahl-binding/ahl-binding.hpp index 62a518e..66fce84 100644 --- a/ahl-binding/ahl-binding.hpp +++ b/ahl-binding/ahl-binding.hpp @@ -21,11 +21,12 @@ #include #include #include +#include #include #include #include "config_entry.hpp" -#include "ahl-4a.hpp" +#include "role.hpp" #define HL_API_NAME "ahl-4a" #define HL_API_INFO "Audio high level API for AGL applications" @@ -37,55 +38,27 @@ extern "C" { #include #include #include - - int afbBindingVdyn(afb_dynapi* handle); - int ahl_api_create(void*, struct afb_dynapi*); }; -namespace ext -{ - template - typename T::iterator find(T& container, const typename T::value_type& value) - { - return std::find(std::begin(container), std::end(container), value); - } - - template - typename T::iterator find_if(T& container, UnaryPredicate pred) - { - return std::find_if(std::begin(container), std::end(container), pred); - } - - template - typename T::iterator cfind_if(T& container, UnaryPredicate pred) - { - return std::find_if(std::begin(container), std::end(container), pred); - } -} - class ahl_binding_t { using role_action = std::function; private: afb_dynapi* handle_; - - ahl_4a_t config_; - std::map actions_; - std::vector opened_roles_; + std::vector roles_; explicit ahl_binding_t(); void load_static_verbs(); - void load_controller_api(); + + + void load_controller_configs(); int load_controller_config(const std::string& path); - int load_config(CtlSectionT* section, json_object* o); + int update_streams(); + void update_stream(std::string hal, std::string stream, std::string deviceuri); + int create_api_verb(role_t* r); - void volume(afb_request* req, std::string role, std::string stream, json_object* arg); - void open(afb_request* req, std::string role, std::string stream, json_object* arg); - void close(afb_request* req, std::string role, std::string stream, json_object* arg); - void interrupt(afb_request* req, std::string role, std::string stream, json_object* arg); - void policy_open(afb_request* req, const role_t& role); public: @@ -93,8 +66,13 @@ public: int preinit(afb_dynapi* handle); int init(); void event(std::string name, json_object* arg); - void audiorole(afb_request* req); void get_roles(afb_request* req); + + const std::vector roles() const; + afb_dynapi* handle() const; + + void audiorole(afb_request* req); + int parse_roles_config(json_object* o); }; -- cgit 1.2.3-korg