diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-03-08 12:08:11 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-03-08 08:29:35 +0000 |
commit | 08a28337118f5474b6ce73d3024dbd88d994cb93 (patch) | |
tree | a174adc62b97c86bb8a76c293a621c5edcbdb5c7 /src/soundmanager.c | |
parent | d17141136e7b75c174babce5b15e56fde6de063b (diff) |
Clean: clean up duplicate code
Change-Id: I99fdddbefa5fbb36bd0185a7541c7ff4eb4c921f
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/soundmanager.c')
-rw-r--r-- | src/soundmanager.c | 82 |
1 files changed, 17 insertions, 65 deletions
diff --git a/src/soundmanager.c b/src/soundmanager.c index 2c67f83..d8df22e 100644 --- a/src/soundmanager.c +++ b/src/soundmanager.c @@ -101,11 +101,7 @@ void connect (struct afb_req request) &main_connectionID, NULL, &err); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; /* ToDo Remember appname(key) and tie to sourceID(value) */ @@ -142,11 +138,7 @@ void disconnect (struct afb_req request) NULL, &err); AFB_DEBUG( "ret = %d", ret); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; struct json_object* res_obj = json_object_new_object(); sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2, @@ -182,11 +174,7 @@ void setVolume (struct afb_req request) NULL, &err); AFB_DEBUG( "ret = %d", ret); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; struct json_object* res_obj = json_object_new_object(); sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2, @@ -222,11 +210,7 @@ void volumeStep (struct afb_req request) NULL, &err); AFB_DEBUG( "ret = %d", ret); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; struct json_object* res_obj = json_object_new_object(); sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2, @@ -263,11 +247,7 @@ void setSinkMuteState(struct afb_req request) NULL, &err); AFB_DEBUG( "ret = %d", ret); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; struct json_object* res_obj = json_object_new_object(); sm_add_object_to_json_object_func(res_obj, __FUNCTION__, 2, @@ -292,11 +272,7 @@ void getListMainConnections(struct afb_req request) &err ); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; /* create response */ struct json_object *array_res = json_object_new_array(); @@ -349,11 +325,7 @@ void getListMainSources(struct afb_req request) &err ); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; /* create response */ struct json_object *response = json_object_new_object(); @@ -411,11 +383,7 @@ void getListMainSinks(struct afb_req request) &err ); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; /* create response */ struct json_object *response = json_object_new_object(); @@ -498,11 +466,8 @@ void ackConnect(struct afb_req request) error, NULL, &err); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; + /*create response json object*/ struct json_object *res = json_object_new_object(); sm_add_object_to_json_object_func(res, __FUNCTION__, 2, @@ -541,11 +506,8 @@ void ackDisconnect(struct afb_req request) error, NULL, &err); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; + /*create response json object*/ struct json_object *res = json_object_new_object(); sm_add_object_to_json_object_func(res, __FUNCTION__, 2, @@ -578,11 +540,8 @@ void ackSetSourceState(struct afb_req request) error, NULL, &err); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; + /*create response json object*/ struct json_object *res = json_object_new_object(); sm_add_object_to_json_object_func(res, __FUNCTION__, 2, @@ -684,11 +643,7 @@ void registerSource(struct afb_req request) NULL, &err); g_variant_unref(input); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; /*create response json object*/ struct json_object *res = json_object_new_object(); @@ -715,11 +670,8 @@ void deregisterSource(struct afb_req request) &ret, NULL, &err ); - if(err != NULL) - { - afb_req_fail_f(request, "failed", "Unable to call %s", __FUNCTION__); - return; - } + if(!SEND_RESULT(err, request)) return; + /*create response json object*/ struct json_object *res = json_object_new_object(); sm_add_object_to_json_object_func(res, __FUNCTION__, 2, |