summaryrefslogtreecommitdiffstats
path: root/ahl-binding/ahl-binding.hpp
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-06-12 11:00:25 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-06-12 14:40:08 +0000
commit22c2633ac833ae78ff84beafce19cec0f05758a2 (patch)
treedca31bcfc6bf27aaca93e6f9f676361c6f6ed1e1 /ahl-binding/ahl-binding.hpp
parent9a631c30c9c8792865ce2aa0ec06a1bb5fd16751 (diff)
Update to last softmixer and hal, plus some fixes
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 <loic.collignon@iot.bzh>
Diffstat (limited to 'ahl-binding/ahl-binding.hpp')
-rw-r--r--ahl-binding/ahl-binding.hpp52
1 files changed, 15 insertions, 37 deletions
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 <functional>
#include <sstream>
#include <vector>
+#include <list>
#include <map>
#include <cassert>
#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 <afb/afb-binding.h>
#include <string.h>
#include <ctl-config.h>
-
- int afbBindingVdyn(afb_dynapi* handle);
- int ahl_api_create(void*, struct afb_dynapi*);
};
-namespace ext
-{
- template<class T>
- typename T::iterator find(T& container, const typename T::value_type& value)
- {
- return std::find(std::begin(container), std::end(container), value);
- }
-
- template<class T, class UnaryPredicate>
- typename T::iterator find_if(T& container, UnaryPredicate pred)
- {
- return std::find_if(std::begin(container), std::end(container), pred);
- }
-
- template<class T, class UnaryPredicate>
- 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<void(afb_request*, std::string, std::string, json_object*)>;
private:
afb_dynapi* handle_;
-
- ahl_4a_t config_;
- std::map<std::string, role_action> actions_;
- std::vector<role_t> opened_roles_;
+ std::vector<role_t> 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<role_t> roles() const;
+ afb_dynapi* handle() const;
+
+ void audiorole(afb_request* req);
+ int parse_roles_config(json_object* o);
};