aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-23 19:01:34 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-26 08:58:24 +0000
commita8c147ecdb6f0aa2a65c7501537bf28b9e28644e (patch)
tree1c8a7166420443e3d3039adca5710a75ce0102f0 /src
parent2be9164eed151e28452f4db8bb60a1d72c21c2ff (diff)
Change define name
The name which starts with "underscore" should not be used as define. Change-Id: I1b31dddadc301abc299fc8e27d711afdb432b666 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r--src/soundmanager.c211
1 files changed, 106 insertions, 105 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 3719ff9..3677830 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -83,35 +83,35 @@ static struct afb_event ev_async_connect;
static struct afb_event ev_async_disconnect;
static struct afb_event ev_async_set_source_state;
-#define _SOURCE_ID "sourceID"
-#define _SINK_ID "sinkID"
-#define _SINK_NAME "sinkName"
-#define _MAIN_CONNECTION_ID "mainConnectionID"
-#define _DELAY "delay"
-#define _CONNECTION_STATE "connectionState"
-#define _CONNECTION_ID "connectionID"
-#define _VOLUME "volume"
-#define _VOLUME_STEP "volumeStep"
-#define _INTERRUPT "interrupt"
-#define _MUTE_STATE "muteState"
-
-#define _DOMAIN_ID "domainID"
-#define _HANDLE "handle"
-#define _APPNAME "appname"
-#define _RAMP "ramp"
-#define _TIME "time"
-#define _SOURCE_STATE "sourceState"
-#define _SOURCE_CLASS_ID "sourceClassID"
-#define _SINK_CLASS_ID "sinkClassID"
-#define _ERROR "error"
-#define _SINK_DATA "sinkData"
-#define _SOURCE_DATA "sourceData"
-#define _INTERRUPT_STATE "interruptState"
-#define _AVAILABILITY "availability"
-#define _AVAILABILITY_REASON "availabilityReason"
-#define _LIST_VOLUMES "listVolumes"
-#define _PAYLOAD "payload"
-#define _CONNECTION_FORMAT "connectionFormat"
+#define KEY_SOURCE_ID "sourceID"
+#define KEY_SINK_ID "sinkID"
+#define KEY_SINK_NAME "sinkName"
+#define KEY_MAIN_CONNECTION_ID "mainConnectionID"
+#define KEY_DELAY "delay"
+#define KEY_CONNECTION_STATE "connectionState"
+#define KEY_CONNECTION_ID "connectionID"
+#define KEY_VOLUME "volume"
+#define KEY_VOLUME_STEP "volumeStep"
+#define KEY_INTERRUPT "interrupt"
+#define KEY_MUTE_STATE "muteState"
+
+#define KEY_DOMAIN_ID "domainID"
+#define KEY_HANDLE "handle"
+#define KEY_APPNAME "appname"
+#define KEY_RAMP "ramp"
+#define KEY_TIME "time"
+#define KEY_SOURCE_STATE "sourceState"
+#define KEY_SOURCE_CLASS_ID "sourceClassID"
+#define KEY_SINK_CLASS_ID "sinkClassID"
+#define KEY_ERROR "error"
+#define KEY_SINK_DATA "sinkData"
+#define KEY_SOURCE_DATA "sourceData"
+#define KEY_INTERRUPT_STATE "interruptState"
+#define KEY_AVAILABILITY "availability"
+#define KEY_AVAILABILITY_REASON "availabilityReason"
+#define KEY_LIST_VOLUMES "listVolumes"
+#define KEY_PAYLOAD "payload"
+#define KEY_CONNECTION_FORMAT "connectionFormat"
/*
********** Method of Sound Manager (API) **********
*/
@@ -155,11 +155,11 @@ static void connect (struct afb_req request)
REQ_ERROR req_err2 = REQ_FAIL;
GError *err = NULL;
- req_err1 = get_value_uint16(request, _SOURCE_ID, &source_id);
+ req_err1 = get_value_uint16(request, KEY_SOURCE_ID, &source_id);
/* ToDo: Hardware abstraction for application user is needed.
select appname(speaker) or sourceID(sinkID). If appname is desired, it changes to sourceID(sinkID) */
- const char* default_sink = afb_req_value (request, _SINK_ID);
+ const char* default_sink = afb_req_value (request, KEY_SINK_ID);
if(default_sink != NULL){
if((strlen("default") == strlen(default_sink)) &&
(0 == strncmp("default", default_sink, strlen("default")))){
@@ -167,7 +167,7 @@ static void connect (struct afb_req request)
req_err2 = REQ_OK;
}
else{
- req_err2 = get_value_uint16(request, _SINK_ID, &sink_id);
+ req_err2 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
}
}
@@ -199,7 +199,7 @@ static void connect (struct afb_req request)
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
"error", ret,
- _MAIN_CONNECTION_ID, main_connectionID);
+ KEY_MAIN_CONNECTION_ID, main_connectionID);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -229,12 +229,12 @@ static void disconnect (struct afb_req request)
REQ_ERROR req_err;
GError *err = NULL;
- req_err = get_value_uint16(request, _MAIN_CONNECTION_ID, &id);
- AFB_DEBUG( "requested %s = %d", _MAIN_CONNECTION_ID, id);
+ req_err = get_value_uint16(request, KEY_MAIN_CONNECTION_ID, &id);
+ AFB_DEBUG( "requested %s = %d", KEY_MAIN_CONNECTION_ID, id);
if(req_err != REQ_OK)
{
- afb_req_fail(request,"wrong-request",afb_req_value (request, _MAIN_CONNECTION_ID));
+ afb_req_fail(request,"wrong-request",afb_req_value (request, KEY_MAIN_CONNECTION_ID));
return;
}
audiomanager_commandinterface_call_disconnect_sync(
@@ -252,7 +252,7 @@ static void disconnect (struct afb_req request)
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res_obj, info); /* return error num as status */
@@ -282,9 +282,9 @@ static void setVolume (struct afb_req request)
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
- req_err1 = get_value_uint16(request, _SINK_ID, &sink_id);
- req_err2 = get_value_int16(request, _VOLUME, &vol);
- AFB_DEBUG( "requested %s = %d, %s = %d",_SINK_ID, sink_id, _VOLUME, vol);
+ req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
+ req_err2 = get_value_int16(request, KEY_VOLUME, &vol);
+ AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_VOLUME, vol);
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
afb_req_fail(request,"wrong-request", NULL);
@@ -338,9 +338,9 @@ static void volumeStep (struct afb_req request)
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
- req_err1 = get_value_uint16(request, _SINK_ID, &sink_id);
- req_err2 = get_value_int16(request, _VOLUME_STEP, &vol);
- AFB_DEBUG( "requested %s = %d, %s = %d",_SINK_ID, sink_id, _VOLUME_STEP, vol);
+ req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
+ req_err2 = get_value_int16(request, KEY_VOLUME_STEP, &vol);
+ AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_VOLUME_STEP, vol);
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
afb_req_fail(request,"wrong-request", NULL);
@@ -394,9 +394,10 @@ static void setSinkMuteState(struct afb_req request)
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
- req_err1 = get_value_uint16(request, _SINK_ID, &sink_id);
- req_err2 = get_value_int16(request, _MUTE_STATE, &mute);
- AFB_DEBUG( "requested %s = %d, %s = %d",_SINK_ID, sink_id, _MUTE_STATE, mute);
+ req_err1 = get_value_uint16(request, KEY_SINK_ID, &sink_id);
+ req_err2 = get_value_int16(request, KEY_MUTE_STATE, &mute);
+ AFB_DEBUG( "requested %s = %d, %s = %d",KEY_SINK_ID, sink_id, KEY_MUTE_STATE, mute);
+
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
afb_req_fail(request,"wrong-request", NULL);
@@ -485,11 +486,11 @@ static void getListMainConnections(struct afb_req request)
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj,10,
- _MAIN_CONNECTION_ID, mcid,
- _SOURCE_ID, srcid,
- _SINK_ID, sinkid,
- _DELAY, delay,
- _CONNECTION_STATE, constate
+ KEY_MAIN_CONNECTION_ID, mcid,
+ KEY_SOURCE_ID, srcid,
+ KEY_SINK_ID, sinkid,
+ KEY_DELAY, delay,
+ KEY_CONNECTION_STATE, constate
);
json_object_array_add(array_res,res_obj);
}
@@ -558,18 +559,18 @@ static void getListMainSinks(struct afb_req request)
g_variant_get(
child,"(qs(nn)nnq)",
&sinkid, &sinkname, &av, &avr, &volume, &mutestate, &sinkclassid);
- AFB_DEBUG( "sinkID: %d, sinkName: %s, availability: %d, available_reason: %d, volume: %d, muteState: %d, sinkClassID: %d",
+ AFB_DEBUG( "sinkID: %d, sinkName: %s, availability: %d, availableReason: %d, volume: %d, muteState: %d, sinkClassID: %d",
sinkid, sinkname, av, avr, volume, mutestate, sinkclassid);
struct json_object* res_obj = json_object_new_object();
- sm_add_object_to_json_object(res_obj,2,_SINK_ID, sinkid);
- json_object_object_add(res_obj, _SINK_NAME, json_object_new_string(sinkname));
+ sm_add_object_to_json_object(res_obj,2,KEY_SINK_ID, sinkid);
+ json_object_object_add(res_obj, KEY_SINK_NAME, json_object_new_string(sinkname));
sm_add_object_to_json_object(res_obj,10,
- _AVAILABILITY, av,
- _AVAILABILITY_REASON, avr,
- _VOLUME, volume,
- _MUTE_STATE, mutestate,
- _SINK_CLASS_ID, sinkclassid);
+ KEY_AVAILABILITY, av,
+ KEY_AVAILABILITY_REASON, avr,
+ KEY_VOLUME, volume,
+ KEY_MUTE_STATE, mutestate,
+ KEY_SINK_CLASS_ID, sinkclassid);
json_object_array_add(array_res,res_obj);
g_variant_unref(child);
}
@@ -613,9 +614,9 @@ static void ackConnect(struct afb_req request)
REQ_ERROR req_err1, req_err2 , req_err3;
GError *err = NULL;
- req_err1 = get_value_uint16(request, _HANDLE, &handle);
- req_err2 = get_value_uint16(request, _CONNECTION_ID, &connection_id);
- req_err3 = get_value_uint16(request, _ERROR, &error);
+ req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
+ req_err2 = get_value_uint16(request, KEY_CONNECTION_ID, &connection_id);
+ req_err3 = get_value_uint16(request, KEY_ERROR, &error);
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
{
@@ -643,7 +644,7 @@ static void ackConnect(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -674,10 +675,10 @@ static void ackDisconnect(struct afb_req request)
guint16 ret = 0;
REQ_ERROR req_err1, req_err2 , req_err3;
GError *err = NULL;
+ req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
+ req_err2 = get_value_uint16(request, KEY_CONNECTION_ID, &connection_id);
+ req_err3 = get_value_uint16(request, KEY_ERROR, &error);
- req_err1 = get_value_uint16(request, _HANDLE, &handle);
- req_err2 = get_value_uint16(request, _CONNECTION_ID, &connection_id);
- req_err3 = get_value_uint16(request, _ERROR, &error);
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK) || (req_err3 != REQ_OK))
{
@@ -705,7 +706,7 @@ static void ackDisconnect(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -734,9 +735,9 @@ static void ackSetSourceState(struct afb_req request)
guint16 ret = 0;
REQ_ERROR req_err1, req_err2;
GError *err = NULL;
+ req_err1 = get_value_uint16(request, KEY_HANDLE, &handle);
+ req_err2 = get_value_uint16(request, KEY_ERROR, &error);
- req_err1 = get_value_uint16(request, _HANDLE, &handle);
- req_err2 = get_value_uint16(request, _ERROR, &error);
if((req_err1 != REQ_OK) || (req_err2 != REQ_OK))
{
@@ -759,7 +760,7 @@ static void ackSetSourceState(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -795,10 +796,10 @@ static void registerSource(struct afb_req request)
gint32 source_state; /* i */
gint16 volume; /* n */
- if(REQ_OK != get_value_uint16(request, _SOURCE_ID, &source_id)){
+ if(REQ_OK != get_value_uint16(request, KEY_SOURCE_ID, &source_id)){
source_id = DYNAMIC_SOURCE_ID; /* if 0, dynamic source id will be applied */
}
- REQ_ERROR req_err = get_value_uint16(request, _DOMAIN_ID, &domain_id);
+ REQ_ERROR req_err = get_value_uint16(request, KEY_DOMAIN_ID, &domain_id);
if( req_err != REQ_OK){
if(req_err == REQ_FAIL)
{
@@ -814,20 +815,20 @@ static void registerSource(struct afb_req request)
afb_req_fail(request,"wrong-request", "domainID should be more than 0");
return;
}
- const gchar* name = afb_req_value(request, _APPNAME); /* s */
+ const gchar* name = afb_req_value(request, KEY_APPNAME); /* s */
if(!name)
{
char* info = "Must specify the name. Please input json arg such as {\"appname\":\"radio\"}";
afb_req_fail(request, NULL, info);
return;
}
- if(REQ_OK != get_value_uint16(request, _SOURCE_CLASS_ID, &source_class_id)){
+ if(REQ_OK != get_value_uint16(request, KEY_SOURCE_CLASS_ID, &source_class_id)){
source_class_id = DEFAULT_SOURCE_CLASS_ID; /* BASE */
}
- if(REQ_OK != get_value_int32(request, _SOURCE_STATE, &source_state)){
+ if(REQ_OK != get_value_int32(request, KEY_SOURCE_STATE, &source_state)){
source_state = DEFAULT_SOURCE_STATE; /* SS_OFF */
}
- if(REQ_OK != get_value_int16(request, _VOLUME, &volume)){
+ if(REQ_OK != get_value_int16(request, KEY_VOLUME, &volume)){
volume = DEFAULT_VOLUME;
}
gboolean visible = TRUE; /* b */
@@ -836,7 +837,7 @@ static void registerSource(struct afb_req request)
available.avalilable_reason = 0; /* AR_UNKNOWN */
guint16 interrupt;
- if(REQ_OK != get_value_int16(request, _INTERRUPT, &interrupt)){
+ if(REQ_OK != get_value_int16(request, KEY_INTERRUPT, &interrupt)){
interrupt = DEFAULT_INTERRUPT; /* q IS_OFF */
}
struct sound_property_s sound_property_list; /* a(in) */
@@ -885,8 +886,8 @@ static void registerSource(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
- _ERROR, ret,
- _SOURCE_ID, acquire_source_id);
+ KEY_ERROR, ret,
+ KEY_SOURCE_ID, acquire_source_id);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -911,7 +912,7 @@ static void deregisterSource(struct afb_req request)
GError *err = NULL;
- if(REQ_OK != get_value_uint16(request, _SOURCE_ID, &source_id)){
+ if(REQ_OK != get_value_uint16(request, KEY_SOURCE_ID, &source_id)){
afb_req_fail(request, "wrong-request", NULL);
}
audiomanager_routinginterface_call_deregister_source_sync(
@@ -928,7 +929,7 @@ static void deregisterSource(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
@@ -978,7 +979,7 @@ static void subscribe(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -1027,7 +1028,7 @@ static void unsubscribe(struct afb_req request)
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
- _ERROR, ret);
+ KEY_ERROR, ret);
char *info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -1108,11 +1109,11 @@ static void on_new_main_connection(AudiomanagerCommandinterface* interface,
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj,10,
- _MAIN_CONNECTION_ID, mcid,
- _SOURCE_ID, srcid,
- _SINK_ID, sinkid,
- _DELAY, delay,
- _CONNECTION_STATE, constate
+ KEY_MAIN_CONNECTION_ID, mcid,
+ KEY_SOURCE_ID, srcid,
+ KEY_SINK_ID, sinkid,
+ KEY_DELAY, delay,
+ KEY_CONNECTION_STATE, constate
);
AFB_DEBUG("json object :%s:",json_object_to_json_string(res_obj));
@@ -1126,7 +1127,7 @@ static void on_removed_main_connection(
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj, 2,
- _MAIN_CONNECTION_ID, mainConnectionID);
+ KEY_MAIN_CONNECTION_ID, mainConnectionID);
afb_event_push(ev_removed_main_connection, res_obj);
}
@@ -1137,8 +1138,8 @@ static void on_main_connection_state_changed(
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj, 4,
- _CONNECTION_ID, connectionID,
- _CONNECTION_STATE, connectionState);
+ KEY_CONNECTION_ID, connectionID,
+ KEY_CONNECTION_STATE, connectionState);
afb_event_push(ev_main_connection_state_changed, res_obj);
}
@@ -1148,8 +1149,8 @@ static void on_volume_changed(
AFB_DEBUG("%s is called",__FUNCTION__);
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj, 4,
- _SINK_ID, sinkID,
- _VOLUME, volume);
+ KEY_SINK_ID, sinkID,
+ KEY_VOLUME, volume);
afb_event_push(ev_volume_changed, res_obj);
}
@@ -1159,8 +1160,8 @@ static void on_sink_mute_state_changed(
AFB_DEBUG("%s is called",__FUNCTION__);
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object(res_obj, 4,
- _SINK_ID, sinkID,
- _MUTE_STATE, mute);
+ KEY_SINK_ID, sinkID,
+ KEY_MUTE_STATE, mute);
afb_event_push(ev_sink_mute_state_changed, res_obj);
}
@@ -1213,11 +1214,11 @@ static gboolean on_async_connect(
struct json_object* ev_obj = json_object_new_object();
sm_add_object_to_json_object(ev_obj, 10,
- _HANDLE, arg_handle,
- _CONNECTION_ID, arg_connectionID,
- _SOURCE_ID, arg_sourceID,
- _SINK_ID, arg_sinkID,
- _CONNECTION_FORMAT, arg_connectionFormat);
+ KEY_HANDLE, arg_handle,
+ KEY_CONNECTION_ID, arg_connectionID,
+ KEY_SOURCE_ID, arg_sourceID,
+ KEY_SINK_ID, arg_sinkID,
+ KEY_CONNECTION_FORMAT, arg_connectionFormat);
afb_event_push(ev_async_connect, ev_obj);
/* GError must be initialized here because it is same as grobal errno,
@@ -1246,8 +1247,8 @@ static gboolean on_async_disconnect(
AFB_DEBUG( "%s called", __FUNCTION__);
struct json_object* ev_obj = json_object_new_object();
sm_add_object_to_json_object(ev_obj, 4,
- _HANDLE, arg_handle,
- _CONNECTION_ID, arg_connectionID);
+ KEY_HANDLE, arg_handle,
+ KEY_CONNECTION_ID, arg_connectionID);
afb_event_push(ev_async_disconnect, ev_obj);
GError* err = NULL;
audiomanager_routinginterface_call_ack_disconnect_sync(
@@ -1315,9 +1316,9 @@ static gboolean on_async_set_source_state(
struct json_object* ev_obj = json_object_new_object();
char* ss_key = get_source_state_key(arg_sourceState);
sm_add_object_to_json_object(ev_obj, 4,
- _HANDLE, arg_handle,
- _SOURCE_ID, arg_sourceID);
- json_object_object_add(ev_obj, _SOURCE_STATE, json_object_new_string(ss_key));
+ KEY_HANDLE, arg_handle,
+ KEY_SOURCE_ID, arg_sourceID);
+ json_object_object_add(ev_obj, KEY_SOURCE_STATE, json_object_new_string(ss_key));
afb_event_push(ev_async_set_source_state, ev_obj);
/* Applications must return ackSetSourceState to look sourceID, then Sound Manager doen't return ackSetSourceState */
/*audiomanager_routinginterface_call_ack_set_source_state_sync(