From bb46bb9c1a487cf4a3121862d32a20e4770cad99 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 8 Dec 2017 13:25:08 +0900 Subject: Remove redundant functions I decided that libsoundmanager doesn't have multi callback entry point to simplify API. Change-Id: I6e4a94148399c09b7603e8f9cf9a62f29f5e80fb Signed-off-by: Kazumasa Mitsunari --- src/libsoundmanager.cpp | 66 ------------------------------------------------- src/libsoundmanager.hpp | 5 ---- 2 files changed, 71 deletions(-) diff --git a/src/libsoundmanager.cpp b/src/libsoundmanager.cpp index 5c4ba61..25125d2 100644 --- a/src/libsoundmanager.cpp +++ b/src/libsoundmanager.cpp @@ -204,28 +204,6 @@ void Soundmanager::registerCallback( onHangup = hangup_cb; } -/** - * This function is overload of registerCallback. This registers callback function for reply/event message from sound manager - * - * #### Parameters - * - reply_cb [in] : This argument should be specified to the reply callback for call function - * - hangup_cb [in] : This argument should be specified to the hangup callback for call function. nullptr is defaulty set. - * - * #### Return - * - * #### Note - * Event callback is invoked by sound manager for event you subscribed. - * This function for convinience for user uses set_event_handler - * If you would like to get event, please call subscribe function before/after this function - */ -void Soundmanager::registerCallback( - void (*reply_cb)(struct json_object* reply_contents), - void (*hangup_cb)(void)) -{ - onReply = reply_cb; - onHangup = hangup_cb; -} - /** * This function calls registerSource of Audio Manager via WebSocket * registerSource is registration as source for policy management @@ -496,28 +474,6 @@ int Soundmanager::unsubscribe(const string& event_name) return ret; } -/** - * This function calls the ackSetSourceState of Audio Manager via WebSocket - * - * #### Parameters - * - EventType_AsyncSetSourceState [in] : This parameter is EventType of soundmanager - * - handler_func [in] : This parameter is callback function - * - * #### Return - * - Returns 0 on success or -1 in case of transmission error. - * - * #### Note - * This function must be called when application get asyncSetSourceState event - * Input handle number attached in asyncSetSourceState and error number(0 is acknowledge) - */ -void Soundmanager::set_event_handler(enum EventType_SM et, handler_fun f) -{ - if (et > 1 && et < NumItems) { - this->handlers[et] = std::move(f); - } -} - - /************* Callback Function *************/ void Soundmanager::on_hangup(void *closure, struct afb_wsj1 *wsj) @@ -555,8 +511,6 @@ void Soundmanager::on_event(void *closure, const char *event, struct afb_wsj1_ms } else{} - dispatch_event(ev, ev_contents); - json_object_put(ev_contents); } @@ -583,26 +537,6 @@ void Soundmanager::on_reply(void *closure, struct afb_wsj1_msg *msg) json_object_put(reply); } -int Soundmanager::dispatch_event(const string &event , json_object* event_contents){ - //dipatch event - EventType_SM x; - - if(event.find(event_list[0].c_str())){ - x = Event_AsyncSetSourceState; - } - else{ - return -1; - } - auto i = this->handlers.find(x); - if(i != handlers.end()){ - i->second(event_contents); - return 0; - } - else{ - return -1; - } -} - /* Internal Function in libsoundmanager */ static void _ELOG(const char* func, const int line, const char* log, ...) diff --git a/src/libsoundmanager.hpp b/src/libsoundmanager.hpp index 183709e..2632f94 100644 --- a/src/libsoundmanager.hpp +++ b/src/libsoundmanager.hpp @@ -54,19 +54,14 @@ public: int call(const char* verb, struct json_object* arg); int subscribe(const std::string& event_name); int unsubscribe(const std::string& event_name); - void set_event_handler(enum EventType_SM et, handler_fun f); void registerCallback( void (*event_cb)(const std::string& event, struct json_object* event_contents), void (*reply_cb)(struct json_object* reply_contents), void (*hangup_cb)(void) = nullptr); - void registerCallback( - void (*reply_cb)(struct json_object* reply_contents), - void (*hangup_cb)(void) = nullptr); private: int init_event(); int initialize_websocket(); - int dispatch_event(const std::string& event, struct json_object* ev_contents); void (*onEvent)(const std::string& event, struct json_object* event_contents); void (*onReply)(struct json_object* reply); -- cgit 1.2.3-korg