aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2017-12-06 22:24:32 +0100
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2017-12-08 14:11:23 +0000
commit6714ef6f8c878c9d2b6aa673013c4c658c9cd8a9 (patch)
treed2fb43b34bb4d225b9d39b83f25fbc4061dd4030
parent075c692e3ff44460fb0f31d1c2305dc58e8f1f58 (diff)
MOST_UNICENS: hal_most_unicens.c: Remove superfluous initialization code
Remove superfluous code to initialize the agl-service-unicens. Due to widget dependency this service is already initialized and the default network configuration is loaded. Remove trailing whitespaces. Contributes to SPEC-1167 Bug-AGL: SPEC-1167 Change-Id: Ie9af13589214c1cbad536720228d5942f5ea316e Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com>
-rw-r--r--MOST_UNICENS/hal_most_unicens.c64
1 files changed, 18 insertions, 46 deletions
diff --git a/MOST_UNICENS/hal_most_unicens.c b/MOST_UNICENS/hal_most_unicens.c
index 775f2c4..39cf14d 100644
--- a/MOST_UNICENS/hal_most_unicens.c
+++ b/MOST_UNICENS/hal_most_unicens.c
@@ -22,10 +22,6 @@
#include "wrap_unicens.h"
#include "wrap_volume.h"
-#ifndef UCS2_CFG_PATH
-# define UCS2_CFG_PATH "/home/agluser/DEVELOPMENT/AGL/BINDING/unicens2-binding/data"
-#endif
-
#define ALSA_CARD_NAME "Microchip MOST:1"
#define ALSA_DEVICE_ID "hw:1"
#define PCM_MAX_CHANNELS 6
@@ -35,12 +31,12 @@ static json_bool master_switch;
static int pcm_volume[PCM_MAX_CHANNELS];
static void unicens_apply_card_value(void *closure, struct json_object *j_obj){
-
+
int num_id = 0;
int values[6];
-
+
/* apply master volume */
- if (wrap_json_unpack(j_obj, "{s:i, s:[i!]}", "id", &num_id, "val",
+ if (wrap_json_unpack(j_obj, "{s:i, s:[i!]}", "id", &num_id, "val",
&values[0])
== 0) {
if (num_id == 1) {
@@ -52,7 +48,7 @@ static void unicens_apply_card_value(void *closure, struct json_object *j_obj){
}
}
- if (wrap_json_unpack(j_obj, "{s:i, s:[iiiiii!]}", "id", &num_id, "val",
+ if (wrap_json_unpack(j_obj, "{s:i, s:[iiiiii!]}", "id", &num_id, "val",
&values[0], &values[1], &values[2], &values[3], &values[4], &values[5])
== 0) {
if (num_id == 2) {
@@ -61,44 +57,39 @@ static void unicens_apply_card_value(void *closure, struct json_object *j_obj){
return;
}
}
-
+
AFB_ERROR("unicens_apply_card_value: no card value applied");
}
static void unicens_request_card_values_cb(void *closure, int status, struct json_object *j_response) {
-
+
json_object *j_obj;
-
+
AFB_INFO("unicens_request_card_values_cb: closure=%p status=%d, res=%s", closure, status, json_object_to_json_string(j_response));
-
+
if (json_object_object_get_ex(j_response, "response", &j_obj)) {
-
+
wrap_json_optarray_for_all(j_obj, &unicens_apply_card_value, NULL);
}
}
-__attribute__ ((unused)) static void unicens_request_card_values(const char* dev_id) {
+static void unicens_request_card_values(const char* dev_id) {
int err;
json_object *j_query = NULL;
-
+
err = wrap_json_pack(&j_query, "{s:s, s:i}", "devid", dev_id, "mode", 0);
if (err) {
AFB_ERROR("Failed to call wrap_json_pack");
goto OnErrorExit;
- }
+ }
afb_service_call("alsacore", "ctlget", j_query,
&unicens_request_card_values_cb,
NULL);
-
- if (err) {
- AFB_ERROR("Failed to call listconfig");
- goto OnErrorExit;
- }
-
+
OnErrorExit:
return;
}
@@ -167,7 +158,6 @@ STATIC alsaHalSndCardT alsaHalSndCard = {
/* initializes ALSA sound card, UNICENS API */
STATIC int unicens_service_init() {
int err = 0;
- char *config_file = NULL;
AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING");
err = halServiceInit(afbBindingV2.api, &alsaHalSndCard);
@@ -182,39 +172,21 @@ STATIC int unicens_service_init() {
goto OnErrorExit;
}
- err = wrap_ucs_getconfig_sync(UCS2_CFG_PATH, &config_file);
- if (err || (config_file == NULL)) {
- AFB_ERROR("Failed to retrieve configuration");
- goto OnErrorExit;
- }
- else {
- AFB_NOTICE("Found configuration: %s", config_file);
- }
-
err = wrap_ucs_subscribe_sync();
if (err) {
AFB_ERROR("Failed to subscribe to UNICENS binding");
goto OnErrorExit;
}
- err = wrap_ucs_initialize_sync(config_file);
- free(config_file);
- config_file = NULL;
-
- if (err) {
- AFB_ERROR("Failed to initialize UNICENS binding");
- goto OnErrorExit;
- }
-
err = wrap_volume_init();
if (err) {
AFB_ERROR("Failed to initialize wrapper for volume library");
goto OnErrorExit;
}
-
+
/* request of initial card values */
unicens_request_card_values(ALSA_DEVICE_ID);
-
+
OnErrorExit:
AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING done..");
return err;
@@ -231,7 +203,7 @@ PUBLIC void unicens_event_cb(const char *evtname, json_object *j_event) {
if (strncmp(evtname, "UNICENS/", 8) == 0) {
//AFB_NOTICE("unicens_event_cb: evtname=%s, event=%s", evtname, json_object_get_string(j_event));
if (strcmp(evtname, "UNICENS/node-availibility") == 0) {
-
+
int node;
int available;
if (wrap_json_unpack(j_event, "{s:i,s:b}", "node", &node, "available", &available) == 0) {
@@ -239,10 +211,10 @@ PUBLIC void unicens_event_cb(const char *evtname, json_object *j_event) {
wrap_volume_node_avail(node, available);
}
}
-
+
return;
}
-
+
AFB_NOTICE("unicens_event_cb: UNHANDLED EVENT, evtname=%s, event=%s", evtname, json_object_get_string(j_event));
}