aboutsummaryrefslogtreecommitdiffstats
path: root/src/soundmanager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/soundmanager.c')
-rw-r--r--src/soundmanager.c71
1 files changed, 34 insertions, 37 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 2ad3c08..7b929a2 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -115,7 +115,7 @@ void connect (struct afb_req request)
ErrorCode ec = am_proxy_connect(source_id, source_id, &main_connectionID);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/* ToDo Remember appname(key) and tie to sourceID(value) */
@@ -124,7 +124,7 @@ void connect (struct afb_req request)
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
"error", ec,
KEY_MAIN_CONNECTION_ID, main_connectionID);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res, info);
}
@@ -147,12 +147,12 @@ void disconnect (struct afb_req request)
ErrorCode ec = am_proxy_disconnect(main_connection_id);
AFB_DEBUG( "ret = %d", ec);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
KEY_ERROR, ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res_obj, info); /* return error num as status */
}
@@ -177,12 +177,12 @@ void setVolume (struct afb_req request)
ErrorCode ec = am_proxy_set_volume(sink_id, vol);
AFB_DEBUG( "ret = %d", ec);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
"error", ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res_obj, info); /* return error num as status */
}
@@ -207,12 +207,12 @@ void volumeStep (struct afb_req request)
ErrorCode ec = am_proxy_volume_step(sink_id, vol);
AFB_DEBUG( "ret = %d", ec);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
"error", ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res_obj, info); /* return error num as status */
}
@@ -238,12 +238,12 @@ void setSinkMuteState(struct afb_req request)
ErrorCode ec = am_proxy_set_sink_mute_state(sink_id, mute);
AFB_DEBUG( "ret = %d", ec);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
struct json_object* res_obj = json_object_new_object();
sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2,
"error", ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res_obj, info); /* return error num as status */
}
@@ -257,7 +257,7 @@ void getListMainConnections(struct afb_req request)
ErrorCode ec = am_proxy_get_list_main_connections(mainConnectionList);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/* create response */
struct json_object *array_res = json_object_new_array();
@@ -304,7 +304,7 @@ void getListMainSources(struct afb_req request)
ErrorCode ec = am_proxy_get_list_main_sources(mainSourceList);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/* create response */
struct json_object *response = json_object_new_object();
@@ -356,7 +356,7 @@ void getListMainSinks(struct afb_req request)
ErrorCode ec = am_proxy_get_list_main_sinks(mainSinkList);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/* create response */
struct json_object *response = json_object_new_object();
@@ -415,7 +415,6 @@ void ackConnect(struct afb_req request)
guint16 handle, connection_id, error;
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);
@@ -434,13 +433,13 @@ void ackConnect(struct afb_req request)
ErrorCode ec = am_proxy_ack_connect(handle, connection_id, error);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ret);
- char *info = get_response_audiomanager_massage_error(ret);
+ const char* info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -469,13 +468,13 @@ void ackDisconnect(struct afb_req request)
ErrorCode ec = am_proxy_ack_disconnect(handle, connection_id, error);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ret);
- char *info = get_response_audiomanager_massage_error(ret);
+ const char* info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -499,13 +498,13 @@ void ackSetSourceState(struct afb_req request)
ErrorCode ec = am_proxy_ack_set_source_state(handle, error);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res, info);
}
@@ -595,14 +594,14 @@ void registerSource(struct afb_req request)
ErrorCode ec = am_proxy_register_source(sourceData, &acquire_source_id);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
KEY_ERROR, ec,
KEY_SOURCE_ID, acquire_source_id);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res, info);
}
@@ -616,13 +615,13 @@ void deregisterSource(struct afb_req request)
afb_req_fail(request, "wrong-request", NULL);
}
ErrorCode ec = am_proxy_deregister_source(source_id);
- if(!SEND_RESULT(err, request)) return;
+ if(!SEND_RESULT(ec, request)) return;
/*create response json object*/
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ec);
- char *info = get_response_audiomanager_massage_error(ec);
+ const char* info = get_response_audiomanager_massage_error(ec);
afb_req_success(request, res, info);
}
@@ -660,7 +659,7 @@ void subscribe(struct afb_req request)
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ret);
- char *info = get_response_audiomanager_massage_error(ret);
+ const char* info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -697,7 +696,7 @@ void unsubscribe(struct afb_req request)
struct json_object *res = json_object_new_object();
sm_add_object_to_json_object_func(res, __FUNCTION__, 2,
KEY_ERROR, ret);
- char *info = get_response_audiomanager_massage_error(ret);
+ const char* info = get_response_audiomanager_massage_error(ret);
afb_req_success(request, res, info);
}
@@ -763,16 +762,14 @@ void streamOpen(struct afb_req request){
sm_add_object_to_json_object_func(res, __FUNCTION__, 4,
KEY_ERROR, ret,
KEY_CONNECTION_ID, sid);
- char *info = get_response_audiomanager_massage_error(ret);
+ const char* info = get_response_audiomanager_massage_error(ret);
create_client_context(request, sid, endpoint_id, endpoint_type);
afb_req_success(request, res, info);
}
void streamClose(struct afb_req request){
// TODO : wtite function
- // unpack request
- /* json_object* response = json_object_new_object();
- smClientCtxt* ctxt = afb_req_context_get(request);
+/* smClientCtxt* ctxt = afb_req_context_get(request);
if(ctxt->source.mainConnectionID > 0){
json_object* jreq = json_object_new_object();
json_object_object_add(jreq, KEY_MAIN_CONNECTION_ID, ctxt->source.mainConnectionID);
@@ -913,7 +910,7 @@ static void on_async_set_source_state(void *closure, int handle, int sourceID, i
{
AFB_DEBUG( "%s called", __FUNCTION__);
struct json_object* ev_obj = json_object_new_object();
- char* ss_key = get_source_state_key(sourceState);
+ const char* ss_key = get_source_state_key(sourceState);
sm_add_object_to_json_object(ev_obj, 4,
KEY_HANDLE, handle,
KEY_SOURCE_ID, sourceID);
@@ -1058,8 +1055,8 @@ int sm_init()
.on_async_set_sink_volume = on_async_set_sink_volume,
.on_async_set_source_state = on_async_set_source_state
};
- ErrorCode ret = open_soundmanager_interface(&instruction);
- if(ret != OK){
+ ErrorCode ec = open_soundmanager_interface(&instruction);
+ if(ec != OK){
AFB_ERROR("Failed to create sound manager interface");
return -1;
}
@@ -1074,12 +1071,12 @@ int sm_init()
.complete = TRUE,
.state = DS_CONTROLLED
};
- ret = am_proxy_register_domain( create_domain_data(&ddata), &SOUNDMANAGER_DOMAIN_ID);
- if(!SEND_RESULT_NO_RESP(err)){
+ ec = am_proxy_register_domain( create_domain_data(&ddata), &SOUNDMANAGER_DOMAIN_ID);
+ if(!SEND_RESULT_NO_RESP(ec)){
return -1;
}
- if(ret != OK){
- AFB_ERROR("Failed to registerDomain : %s", get_response_audiomanager_massage_error(ret));
+ if(ec != OK){
+ AFB_ERROR("Failed to registerDomain : %s", get_response_audiomanager_massage_error(ec));
return -1;
}
AFB_DEBUG("domainID : %d", SOUNDMANAGER_DOMAIN_ID);